我正在尝试将GMT转换为IST.
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS");
Date c= sdf.parse("2017-03-31T10:38:14.4723017Z");
Date date = new Date();
DateFormat istFormat = new SimpleDateFormat();
DateFormat gmtFormat = new SimpleDateFormat();
TimeZone gmtTime = TimeZone.getTimeZone("GMT");
TimeZone istTime = TimeZone.getTimeZone("IST");
istFormat.setTimeZone(gmtTime);
gmtFormat.setTimeZone(istTime);
System.out.println("GMT Time: " + istFormat.format(c));
System.out.println("IST Time: " + gmtFormat.format(c));
Run Code Online (Sandbox Code Playgroud)
我的输出是
GMT Time: 31/3/17 6:26 AM
IST Time: 31/3/17 11:56 AM
Run Code Online (Sandbox Code Playgroud)
但我的实际输出应该是
GMT Time: 31/3/17 5:08 AM
IST Time: 31/3/17 10:38 AM
Run Code Online (Sandbox Code Playgroud)
我的代码出了什么问题?