356 questions
9 votes
7 answers
1k views
Given a whole hour of the day, how to find the next whole hour?
I need to iterate through the whole hours of an interval of a particular day. So given the time at one whole hour on the day in question, say, 01:00, how do I find the next whole hour? The next whole ...
0 votes
0 answers
35 views
Spring integration test using H2 and ZonedateTime gives exception
I am writing integration test using H2 with following setup datasource.url=jdbc:h2:mem:service;MODE=PostgreSQL;DB_CLOSE_ON_EXIT=FALSE;DATABASE_TO_LOWER=TRUE;DEFAULT_NULL_ORDERING=HIGH;INIT=RUNSCRIPT ...
-2 votes
1 answer
126 views
Date without Time to ZonedDateTime [closed]
I have an object Date - without a timestamp - thats because of reasons. I use the epoch to get it into a ZonedDateTime - so the epoch is the start of the day at 00:00. java.util.Date d = rs.getDate (&...
1 vote
1 answer
161 views
Difference when creating OffsetDateTime from ZonedDateTime vs LocalDateTime
This code is trying to construct a OffsetDateTime from ZonedDateTime/LocalDatimeTime at Paris timezone. ZoneId paris = ZoneId.of( "Europe/Paris" ); OffsetDateTime offsetDateTime = ...
2 votes
2 answers
258 views
ZonedDateTime produces incorrect date at Europe/Paris vs GMT+1
I am in +07:00 timezone. Given this: ZonedDateTime.of( LocalDateTime.of( 1899, 12, 31, 23, 9, 20, 0 ), ZoneOffset.UTC ) .withZoneSameInstant( ZoneId.of( "Europe/Paris" ) ) Would produce: ...
0 votes
0 answers
39 views
java.time.ZonedDateTime error on JSON conversion to object [duplicate]
I am converting a JSON to an object and it's giving me the following error: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type java.time.LocalDateTime not supported ...
1 vote
1 answer
226 views
Serialize ZonedDateTime in specific format
I would like to make a REST call to a partner system, with Json object in the body. We use ZonedDateTime, and I need to send the dates in the format "2025-01-05T21:41:24.195Z". Currently it ...
0 votes
1 answer
436 views
After Spring boot 3.2.x upgrade , ZoneddateTime is getting persisted in DB always with UTC format
Working scenario: Service-A : with Java 8 , Spring boot 2.7.x Setting the ZoneddateTime ("America/New_York") in java object and adding it in RabbitMQ queue. Service-B : with Java 8 , ...
2 votes
1 answer
556 views
ZonedDateTime in MyBatis
I have a java ZonedDateTime which I am trying to insert into a MySQL Date column (the DBA refuses to change the type - the date should have a time component since it is an audit date/time for when an ...
0 votes
1 answer
466 views
ZonedDateTime with incorrect timezone fetched from database
I have an entity called "Turno" that has an attribute ZonedDateTime. @Column(name = "fecha", nullable = false) @Temporal(TemporalType.TIMESTAMP) private ZonedDateTime ...
0 votes
2 answers
425 views
Java ZonedDateTime.parse not working as expected
I am using Java 17. I am trying to parse different strings as ZonedDateTime but when I try to convert it to an Instant, the output is not as expected. For eg: String first = "2020-01-...
0 votes
1 answer
101 views
Deserialize and serialize ZonedDateTime fields in shared objects between controller based on which controller it is used as a parameter for?
I have this Object, which has a field that is a ZonedDateTime: import java.time.ZonedDateTime; public class TestObject { private ZonedDateTime testTime; public ZonedDateTime getTestTime() { ...
3 votes
1 answer
464 views
java.lang.IllegalArgumentException: Parameter value [2023-12-25T17:19:54.622Z] did not match expected type [java.time.ZonedDateTime (n/a)]
I migrated this code: import org.joda.time.DateTime; @Entity @Table(name = "purchases") @Getter @Setter public class Purchases { @Column(name = "purchase_time") @Type(type = &...
2 votes
1 answer
780 views
ZonedDateTime cannot be parsed from JSON, but parses fine with the formatter
I have this date string coming in through JSON: "29-OCT-21 12.00.00.000000000 AM UTC". I want to save it as a ZonedDateTime data type. I have the property set in the model as such: @...
-1 votes
3 answers
227 views
Java 11 ZonedDateTime - Print Format
How could I manage to get the result of 2023-11-16T09:54:12.123 using the ZonedDateTime object in Java 11? I wrote: zdt.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) and got ISO_LOCAL_DATE_TIME: 2023-...