I have following issue. On client side ( GWT ) I have function
String getFormattedDateFromServer(Date dateFromServer)
which should get date from server in UTC time and return formatted date in client local time
It was implemented as following:
public static String getFormattedDateFromServer(Date dateFromServer) {
int offset = new Date().getTimezoneOffset();
TimeZone localTimeZone = TimeZone.createTimeZone(offset);
return DateTimeFormat.getFormat("MM/dd/yyyy hh:mm").format(dateFromServer, localTimeZone);
}
When running on client in GMT+2 timezone on date 04/05/2020 00:00 it was expected 04/05/2020 02:00. But I am getting 04/05/2020 00:00. As I understand this is because on client side date 04/05/2020 00:00 considered already in local time (i.e. GMT+2) .For server side as I see in other posts it can be see via SimpleDateFormat class and manualy set timezon ( like here )
But SimpleDateFormat cannot be used for GWT. The question is how can it be done for GWT ? Or there are better solutions ? Thanks in advance