How to change 2018-12-24 12:00:00 +0800
to 2018-12-23 16:00:00 +0000
in Java?
private String currentDateandTime = new Date();
final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
final DateFormat fullFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss XX", Locale.CHINA);
//dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
//fullFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
Date dateTest = dateFormat.parse(currentDateandTime);
currentDateandTime = fullFormat.format(dateTest);
currentDateanTime Result
2018-12-24 12:00:00 +0800