6
public static void main(String[] args) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("key","2021-03-31T16:06:50+0000");
jsonObject.put("key1","2021-03-31T17:06:50+01:00");
jsonObject.put("key2","2021-03-31T08:06:50-08:00");
jsonObject.put("key3","2021-03-31T10:06:50-06:00");
LocalDateTime localDateTime = jsonObject.getObject( "key", LocalDateTime.class);
LocalDateTime localDateTime1 = jsonObject.getObject( "key1", LocalDateTime.class);
LocalDateTime localDateTime2 = jsonObject.getObject( "key2", LocalDateTime.class);
LocalDateTime localDateTime3 = jsonObject.getObject( "key3", LocalDateTime.class);
System.out.println(localDateTime);
System.out.println(localDateTime1);
System.out.println(localDateTime2);
System.out.println(localDateTime3);
}
正常带了时区字符串转换为本地时间北京时间。 这上面的所有转换后都应该是 2021-04-01 00:06:50 但是得到的结果却不是这样的。