Conversion of local time zone to GMT in java

前端 未结 3 1714
青春惊慌失措
青春惊慌失措 2020-12-30 13:05

Am trying convert date which is in local time zone to GMT, i did some thing like this

SimpleDateFormat sdf = new SimpleDateFormat(\"MM/dd/yyyy HH:mm:ss\");         


        
3条回答
  •  爱一瞬间的悲伤
    2020-12-30 13:32

    After 'parse' you have to again format it before printing, e.g.:

    System.out.println("GMT 2"+sdf.format(gmtDate));
    

    EDIT: The reason is your gmtStrDate doesn't store any timezone information

提交回复
热议问题