简体   繁体   中英

How convert Timezone into specified format?

my java program want TimeZone like GMT(+0530) instead of getting IST
Actually my java code like...

      String date1=null;
      String formate="IST";
      SimpleDateFormat sourceFormat = new SimpleDateFormat("z");

       SimpleDateFormat gmtFormat = new SimpleDateFormat("Z");
       date1 = gmtFormat.format(sourceFormat.parse(formate));
       System.out.println(date1);//output +0530

Problem 1:but Actually i want this format GMT(+0530)

Problem 2:The above code working only passing IST giving +0530 and any zone like EAT,PST also giving +0530 only,... but the time will changed PST = (GMT - 8:00) Please give suggestions...

要打印GMT(+0530)类的格式,请使用模式'GMT('Z')'代替Z

SimpleDateFormat gmtFormat = new SimpleDateFormat("'GMT('Z')'");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM