specific date string format [duplicate]

I think its either yyyy-MM-dd HH:mm:ss.SSS zzz or yyyy-dd-MM HH:mm:ss.SSS zzz

from your example 2016-04-12,it can be 12th april,2016 or 4th december 2016

simple example by considering yyyy-MM-dd HH:mm:ss.SSS zzz

DateFormat gmtFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz");
    TimeZone gmt = TimeZone.getTimeZone("GMT");
    gmtFormat.setTimeZone(gmt);
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
    Date dd = df.parse("2016-04-12 12:18:11.000 EDT");
    System.out.println( gmtFormat.format(dd));

output:2016-04-12 06:48:11.000 GMT

Leave a Comment