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.
A date can be in various formats. Here are few
Let’s 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 the timezone parameter and formatter will do the rest for you.