`ZonedDateTime` is a standard Java class representing a “date-time with a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30+01:00 Europe/Paris.”
Questions tagged [zoneddatetime]
339 questions
8
votes
2 answers
How to convert from java.sql.Date to ZonedDateTime
I am trying to convert from java.sql.Date to ZonedDateTime. This is the code I am using
ZonedDateTime.from(new java.util.Date(result.get(0).getTime()).toInstant())
However, it leads to the following error…

S V
- 570
- 8
- 21
7
votes
2 answers
Timezone of ZonedDateTime changed to UTC during auto conversion of RequestBody with Spring Boot
I'm trying to keep ZoneId of ZonedDateTime which is set on front-end while performing POST/PUT to Spring Boot controller.
The value I want to transfer is:
2019-05-01T00:00:00+01:00[Europe/Zagreb]
After POST/PUT the ZoneId is converted to UTC and…

horvoje
- 643
- 6
- 21
7
votes
3 answers
Whats the difference between java.util.Date and Zoneddatetime?
While using util.date and giving date with time to service from browser and then saving to db and taking it back it gives different date time against setting zoneddatetime directly from service.
Any help would be appreciated..

Vivek Kumar
- 360
- 1
- 7
- 16
7
votes
2 answers
Java - Result when compare two ZonedDateTime is not as expected
I have this code :
ZonedDateTime t1 = ZonedDateTime.parse("2018-04-06T10:01:00.000+03:00");
ZonedDateTime t2 = ZonedDateTime.parse("2018-04-06T10:01:00.000-03:00");
System.out.println(t1.compareTo(t2));
The result is -1. I guess it will convert…

Hai Hoang
- 1,207
- 2
- 18
- 35
7
votes
2 answers
Why does Jackson's default deserializer set the Zone to UTC rather than Z?
I think I must be misunderstanding how Zones work in java's ZonedDateTime class. When I use Jackson to serialize and then deserialize now(), the deserialized value has getZone() == "UTC" instead of the "Z" in the serialized value. Can anyone…

Mark Wright
- 705
- 7
- 20
7
votes
2 answers
ZonedDateTime would use same timezone of winter when summer daylight saving?
ZonedDateTime zdt = ZonedDateTime.of(2015, 10, 18, 0, 30, 0, 0,
ZoneId.of("America/Sao_Paulo"));
System.out.println(zdt); // 2015-10-18T01:30-02:00[America/Sao_Paulo]
You can see the hour is 1 while we set the hour as 0, and timezone is…

Hao Ma
- 711
- 7
- 8
7
votes
3 answers
How to construct ZonedDateTime from an Instant and a time string?
Given an object of Instant, a time string representing the time at a specific ZoneId, How to construct a ZonedDateTime object with the date part (year, month, day) from the instant at the given ZoneId and the time part from the given time…

YAM
- 1,362
- 2
- 16
- 30
6
votes
2 answers
ZonedDateTime format and parsing exception with “z” in format pattern
I have a problem with parsing ZonedDateTime:
DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-ddzhh:mm");
ZonedDateTime.parse(s, formatter);
This results in an error:
java.time.format.DateTimeParseException:
Text…

FrancMo
- 2,459
- 2
- 19
- 39
6
votes
0 answers
ZonedDateTime ISO-8601 parsing: why is colon in timezone ID required?
I have the following tests.
@Test
void withoutColon_fails() {
ZonedDateTime.parse("2019-01-24T12:10:58.036820+0400");
}
@Test
void withColon_ok() {
ZonedDateTime.parse("2019-01-24T12:10:58.036820+04:00");
}
The only difference between the…

Roman Puchkovskiy
- 11,415
- 5
- 36
- 72
6
votes
3 answers
Specify timezone of ZonedDateTime without changing the actual date
I have a Date object which holds a date (not current date) and I need to somehow specify that this date is UTC and then convert it to "Europe/Paris" which is +1 hours.
public static LocalDateTime toLocalDateTime(Date date){
return…

MatMat
- 878
- 3
- 8
- 24
6
votes
1 answer
How to change timezone in ZonedDateTime for Java
What I mean is this. Suppose I have a date object that is May 1, 2018, 12:00AM. I would like to create a ZonedDateTime object that is May 1, 2018, 12:00AM but of ANOTHER time zone (say EST). Because if I pass in that date object into ZonedDateTime,…

Dan James
- 63
- 1
- 1
- 3
6
votes
1 answer
Hibernate Java 8 ZonedDateTime
I am using Hibernate and JPA to store my data in a database.
Now I would like to save a ZonedDateTime from java.time.
The problem is, Hibernate does only ever persist the date and time. It does not care about the ZoneId or the offset.
Is there any…

Mr.H.
- 965
- 1
- 10
- 18
6
votes
1 answer
ZonedDateTime serialize epoch milliseconds with FasterXML Jackson
I'm intended to use epoch millisecond for the deserialization and serialization.
However only the deserialzation works but failed to serialize back to the correct ZonedDateTime.
ObjectMapper mapper = new…

ChinKang
- 4,212
- 2
- 17
- 29
6
votes
2 answers
ZonedDateTime persistance to SQL Database
Good day,
I create web application service, which would be used across the world.
Therefore I need to store datetime values in UTC and represent them in clocks on the wall time to the end user.
After reading Stack overflow, I understood, that I…

Sabine
- 323
- 4
- 14
6
votes
4 answers
Jackson annotation JsonFormat$Value json java.lang.NoSuchMethodError
I am using com.fasterxml.jackson.core:jackson-annotations:2.6.0 in my gradle project. Since adding com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.6.0 to my project build file I have been getting this exception while running my gradle…

Akash Raveendran
- 559
- 1
- 9
- 22