How do you display timezone in Date format?
Use “zzz” instead of “ZZZ”: “Z” is the symbol for an RFC822 time zone. DateFormat formatter = new SimpleDateFormat(“EEE MMM dd HH:mm:ss zzz yyyy”); Having said that, my standard advice on date/time stuff is to use Joda Time, which is an altogether better API.
You can’t change the Date object’s behavior to get it to use a different time zone just by adding or subtracting an offset. It will still use the local time zone of where it runs, for any function that requires a local time, such as . toString() and others.
The timezone is always zero UTC offset, as denoted by the suffix ” Z “. The format you need is created with the . toISOString() method.
How do you code a date in Java?
Get Current Date & Time: java. util. Calendar
- Date date=java.util.Calendar.getInstance().getTime();