Java - Date, Format, Time Zones and Spring Default Boot Options

I have a simple Java object with a date field:

@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date date;

When I examine the date with the debugger, I see:

Wed Jun 14 00:00:00 BST 2017

But as soon as I get it back with help Spring boot controller, I get:

"date": "2017-06-13 23:00:00"
  • What makes the difference?
  • Why BSTdoes Java handle date like ?
  • Does a Java class Datecontain timezone information or just a timestamp in long format?
  • Is it Spring bootused using the UTCdefault format when serializing DTO to JSON?
+4
source share
1 answer

java.util.Date ( long), toString() - ( ).

TimeZone.getDefault(). , Europe/London - , ( Date.toString()) BST.

, Spring, , UTC (as 2017-06-13 23:00:00 in UTC is 2017-06-14 00:00:00 BST).

+1

Source: https://habr.com/ru/post/1679262/


All Articles