Let’s start with 2 basic rules to follow
- Convert Date (java.util.Date) into String => format
- Convert String into Date => parse
I have used SimpleDateFormat which extends DateFormat of java.text package.
Date can be in various format. Here are few
Lets see an Example
Note: Suppose we need to convert String Date format to another String Date format. Implementing above rules, Convert String => Date => String
To get Date time for a particular timezone just pass timezone parameter and formatter will do the rest for you.