I chose a time for example I have entered Thu Jan 01 16:00:00 WET 1970 and also a timezone for example GMT+1:00. I mean that I want to record this date with this time zone (16:00 already in gmt+1). But after saving the model the value is getting saved as Thu Jan 01 15:00:00 WET 1970 in the database.
The server is in Africa/Casablanca timezone.
I tried to convert this date into String with time zone what I want and it shows me the correct time but when I try to convert this string to Date I still receive the time with one hour less.
DisplayedTimeZone displayedTimeZone = configuration.getDisplayedTimeZone();
if(displayedTimeZone != null){
Date orderCuttOffTime = configuration.getCutOffTime(); // Thu Jan 01 15:00:00 WET 1970
if(orderCuttOffTime != null){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
sdf.setTimeZone(TimeZone.getTimeZone(displayedTimeZone.getCode()));
String closingTime = sdf.format(orderCuttOffTime); // 1970-01-01 16:00:00 +0100
try {
configuration.setCutOffTime(dateFormat.parse(cuttOffTime)); // returns again Thu Jan 01 15:00:00 WET 1970 and not 16:00:00
}catch (ParseException e) {
e.printStackTrace();
}
}
}
Even the cuttofftime contains the time Thu 1970-01-01 16:00:00 +0100
that I want to save in database dateFormat.parse(cuttOffTime) returns the value Thu Jan 01 15:00:00 WET 1970
I want during the parse to send me a date with the same time which is in the string