from web, the date is in Asia/Hong_Kong format (UTC+8), but when pass to WildFly server using JSON format, in server debug mode, the date string become UTC format. e.g.
web:Mon Oct 12 2015 00:00:00 GMT+0800 (Hong Kong Standard Time)
WildFly server:2015-10-11T16:00:00.000Z
I want to use java SimpleDateFormat to parse it back to Asia/Hong_Kong format, I try
String dateUTC="2015-10-11T16:00:00.000Z";
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
System.out.println("sdf1.parse(dateUTC)="+sdf1.parse(dateUTC));
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
sdf2.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.println("sdf2.parse(dateUTC)="+sdf2.parse(dateUTC));
SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd");
sdf3.setTimeZone(TimeZone.getTimeZone("Asia/Hong_Kong"));
System.out.println("sdf3.parse(dateUTC)="+sdf3.parse(dateUTC));
I want the output to be "2015-10-12" but fail, the output is
sdf1.parse(dateUTC)=Sun Oct 11 00:00:00 HKT 2015
sdf2.parse(dateUTC)=Sun Oct 11 08:00:00 HKT 2015
sdf3.parse(dateUTC)=Sun Oct 11 00:00:00 HKT 2015
1) So how to make the output to be "2015-10-12"? (As Hong Kong is UTC+8)?
2) any method to make the server can receive the web datetime in Asia/Hong_Kong format, but not in UTC datetime format? I try to set WildFly java_opts by setting VM arguments
-Duser.timezone=Asia/Hong_Kong
but no use, the server still receive the datetime as UTC format.