Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
68 views

Quarkus - JAXB with OffsetDateTime?

I'm trying to deserialize an XML String to a Java Object using Quarkus 3.15 and JAXB. My Java Object has a property with type OffsetDateTime, but when I try to deserialize it I get the following ...
Shadowman's user avatar
  • 12k
1 vote
1 answer
42 views

Swagger Implementation for LocalDateTime type

I want to create a model class that contains createdDate feild type as LocalDateTime using swagger contract, when implementing using swagger contract it is generating offsetDateTime as type in dto. ...
Keerthi's user avatar
  • 11
0 votes
0 answers
124 views

java.time.OffsetDateTime cannot be cast to java.sql.Timestamp after Upgrading the H2database2.2.220

Application is using the Oracle database. And we have the H2 database used for Junit. We were using the h2 version of 1.4.182. Because of the vulnerability we have to upgrade to 2.2.220. When i update ...
raveen raj's user avatar
0 votes
0 answers
79 views

Missing offset on OffsetDatetime on retrieval from DB

Hello I am struggling with zone offset on OffsetDatetime fields I have in my app. I simulated it in tests. I created a datetime which is displayed as 2023-12-25T09:53:55+01:00 when debugging. When I ...
David Bulko's user avatar
0 votes
1 answer
817 views

date not format as in hibernate 5 with jsonb in hibernate 6

I am migrating to quarkus 3 and i couldnt find a way to serialize properly (like in hibernate 5) my OffsetDateTime for a field annotated with jsonb in an entity : This is one of my entity, ...
AJO's user avatar
  • 33
0 votes
0 answers
98 views

Convert String value to OffsetDateTime [duplicate]

I have the following code: public class Objc{ OffsetDateTime purchaseDate = new OffsetDateTime(); // getter/setter } .... String buyDate = ......; objc....
Peter Penzov's user avatar
  • 1,738
0 votes
0 answers
42 views

Unusual Behavior of OffsetDateTime.now() on Different Machines [duplicate]

I've encountered a peculiar issue while using OffsetDateTime.now() in my Java code. On my machine, repeated calls to OffsetDateTime.now() return different values each time, which is what I expect. ...
pred1212's user avatar
-1 votes
1 answer
1k views

SQL timestamp not converting to OffsetDateTime

I have a sql timestamp that is being returned from a query in java. I need this date as an OffsetDateTime type, but my attempts to parse it have failed. I've tried the following. What other steps do I ...
Great Gale's user avatar
0 votes
2 answers
1k views

Java Current OffsetDateTime object in UTC with three digit fractional seconds (YYYY-MM-dd'T'HH:mm:ss.SSS'Z')

OffsetDateTime offsetDateTime = OffsetDateTime.now(ZoneId.of("UTC")); Above snippet gives me six-digits fractional seconds, but I need a utility method that returns current OffsetDateTime ...
Naim's user avatar
  • 17
4 votes
2 answers
1k views

Convert timestamp with offset to UTC

Conversion I have a timestamp with an offset (-6) in the following format: 2019-11-30T00:01:00.000-06:00 and I want to convert it to an UTC timestamp, like: 2019-11-30T06:01:00.000Z Attempt I tried ...
F0cus's user avatar
  • 615
0 votes
1 answer
543 views

Deserialize from JSON date "dd.MM.yyyy HH:mm:ss" to OffsetDateTime using ObjectMapper

In tests i m trying to mock response from DB. Json: { description: "testDescription" contactPhone: "123456789" createDate: "18.04.2023 10:33:23" } My POJO has field (...
Nik Korn's user avatar
1 vote
1 answer
867 views

Java OffsetDateTime cannot be parsed [closed]

I want to parse the following String into an OffsetDateTime: OffsetDateTime test = OffsetDateTime.parse("2021-12-31T23:00:00.000+00:00"); However, this results in an exception: java.time....
Lars Wigger's user avatar
0 votes
1 answer
2k views

Deserialize OffsetDataTime java 17

I test endpoints' basic security. Test mvc.perform(MockMvcRequestBuilders.post(path) .contentType(MediaType.APPLICATION_JSON) .content(objectMapper.writeValueAsString(OBJECT)) ...
John Smith's user avatar
5 votes
3 answers
5k views

How to get the date and time in format 2022-10-03T19:45:47.844Z in Java

I need the current system date and time in 2022-10-03T19:45:47.844Z format in a java class. I tried using the zoneddatetime and simple date format but couldn't get the write syntax or code from online....
Pranoy Kakubal's user avatar
1 vote
1 answer
87 views

How to use java `OffsetDateTime` in apache tinkerpop gremlin?

The application can be accessed from a different timezone, so I am trying to store date time using class java.time.OffsetDateTime. startTime: "1996-12-19T16:39:57-08:00", endTime: "1996-...
Thirumal's user avatar
  • 9,461
0 votes
0 answers
460 views

OffsetDateTime nano truncate after save do DB

Me and my colleagues noticed weird behaviour on our local environments (Manjaro & Windows) thanks to integration tests. Field of the type OffsetDateTime differs in nano before and after real save ...
Petr Binčík's user avatar
1 vote
1 answer
694 views

How to keep unknown local offset when converting from RFC3339?

I recieve a timestamp that follows the RFC3339 standard. The sender used the "Unknown Local Offset Convention" provided by RFC3339 as the users time preference is unkown, so I recieve a ...
Nico's user avatar
  • 49
0 votes
0 answers
656 views

Offset not calculated correctly at OffsetDateTime to Instant conversion in Java 8 [duplicate]

I would need the community's help because I could not find the answer in the Java documentation. I don't understand how the offset is taken into the math calculations when I try to convert an ...
Greşanu Emanuel - Vasile's user avatar
0 votes
0 answers
50 views

How can we compare ActionTimestamp and Posteventtimestamp in Java and how to update actiontimestamp to currentTimestamp

How can I compare this timestamp format "20220708T0000Z" with current time and how can we update this timestamp to current time in same format in java, I have tried DateTimeFormatter and ...
sravs's user avatar
  • 1
2 votes
1 answer
1k views

java.lang.UnsupportedOperationException: Cannot have circular references in bean class but got the circular reference of class java.time.ZoneOffset

While executing the below command StructType obs = Encoders.bean(Test.class).schema(); I am getting the below error java.lang.UnsupportedOperationException: Cannot have circular references in bean ...
Vidhi Agarwal's user avatar
1 vote
3 answers
2k views

Spring - How to convert a String representation of Date in JSON body field in request model comming into controller to OffsetDateTime

I have legacy data coming in to my API as part of UserRequest model like @PostMapping public MyResponse saveUser(@Valid @RequestBody UserRequest userRequest) { ... } UserRequest class uses ...
pixel's user avatar
  • 10.5k
1 vote
1 answer
2k views

Jackson serialization of OffsetDateTime with DateTimeFormat.ISO.DATE_TIME ignores zero milliseconds

I have a class that will get serialized into JSON with the following attribute: @JsonProperty("validTo") @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework....
warozell's user avatar
0 votes
1 answer
503 views

Save OffsetDateTime to Room database

I have a data class with a field of type OffsetDateTime. With the room database, I have the following error: Cannot figure out how to read this field from a cursor. private final java.time....
T D Nguyen's user avatar
  • 7,565
1 vote
1 answer
1k views

Generic DateTimeFormatter pattern for ISO 8601 datetime string with zone offset

I have a list of ISO 8601 date strings that I want to parse and convert to OffsetDateTime. Below is how I am converting: var date = OffsetDateTime.parse("2013-03-13T20:59:31-08:00"); This ...
ihaider's user avatar
  • 1,340
0 votes
0 answers
2k views

Issue with OffsetDateTime deserialization from json request body Spring-Boot REST API

I'm having a OffsetDateTime field in my POJO: @NotBlank(message = "startTime cannot be null or empty; ") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss....
Moses's user avatar
  • 11
0 votes
0 answers
693 views

OffsetDateTime does not parse correctly the time when sending a defined time

OffsetDateTime does not correctly parse the time when a defined time is sent to me I have a service with a timezone UTC +4:00 I am sent two possible cases in STRING: 1- 2022-03-30T11:22:33.44+04:00 2-...
AntoCode's user avatar
  • 435
1 vote
0 answers
1k views

How to keep +00:00 instead of Z in XMLGregorianCalendar and OffsetDateTime

I need to serialize(generate Xml String from a Java DTO) and persist the DTO(Oracle DB) using an XSD that has a specific date_time pattern i.e .*(+|-)((0[0-9])|(1[0-3])):[0-5][0-9] which needs to ...
bFren_Sakar's user avatar
0 votes
1 answer
1k views

Custom serialization without annotations

Is there a way on Springboot that I can implement a custom serializer for a specific field on my request without doing annotations? I prefer if we could create a bean or a override a configuration and ...
Rye's user avatar
  • 43
4 votes
1 answer
2k views

How to directly retrieve a UTC OffsetDateTime using MySQL Connector/J?

I prefer all times to be in UTC, except for when they are displayed. At the last moment, they can be converted to a local time for display only. I've always stored UNIX timestamps (seconds since ...
user1902689's user avatar
  • 1,775
0 votes
1 answer
2k views

Calculating "time ago" using OffsetDateTime in Java [duplicate]

I currently have this code: public static String getTimeAgo(OffsetDateTime dateArg) { Instant instantNow = Instant.now(); Instant instantThen = dateArg.toInstant(); Duration ...
uriri's user avatar
  • 25
1 vote
1 answer
7k views

How to format OffsetDateTime in java 13 or above?

In Java 11, clock system uses millisecond precision, but apparently in Java 13 and above, it uses microsecond precision and this causes my tests to fail. As an example, OffsetDateTime.now() gives me ...
Sia's user avatar
  • 63
-3 votes
1 answer
3k views

Why OffsetDateTime serializations/deserialization results have difference?

I have follows object: @Validated @Getter @Setter @AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode @ToString @Schema(description = "Request") public final class Request implements ...
Zhenyria's user avatar
  • 437
1 vote
3 answers
10k views

How to parse DateTime in format yyyyMMddHHmmss to OffsetDateTime using DateFormatter

I have an API for JSON parsing which requires a DateTimeFormatter instance in order to parse date time strings to OffsetDateTime. However I always get an exception Unable to obtain ZoneOffset from ...
Stefan's user avatar
  • 444
3 votes
2 answers
1k views

Java OffsetDateTime returning wrong offset

I have a Java Timestamp value like: 1799-12-31 19:03:58.0 And when I try to convert it into the OffsetDateTime using the code: timestamp.toLocalDateTime().atZone(ZoneId.systemDefault())....
Arthur's user avatar
  • 117
1 vote
0 answers
1k views

Unable to use OffsetDateTime as a query parameter using JPA Data/JPQL

I have an Entity CustomEntity with a data member updateDate of type OffsetDateTime. I have defined a Repository for this Entity which has a simple method to retrieve list of records matching ...
Vishal's user avatar
  • 714
1 vote
2 answers
3k views

I have to get OffsetDateTime from a string

String is in this format - "2021-07-13 05:22:18.712" I tried using this code to parse it. OffsetDateTime parsedDateTime = OffsetDateTime.parse("2021-07-13 05:22:18.712"); But i ...
Vaibhav's user avatar
  • 57
2 votes
2 answers
2k views

OffsetDateTime value is changed when retrieved from the database

I am using a table from MS SQL database and developed a GET API using Spring Boot, to retrieve all the data from that table. Here the table contains a column of type datetimeoffset(7). I have data ...
Vishal's user avatar
  • 714
0 votes
0 answers
1k views

Offset lost for OffsetDateTime with Spring Boot REST Service

I am using java OffsetDateTime to store time both on the client and server side. When I am sending the time information to the server, the local date time part looks like: "2021-06-15T15:43:50&...
Greg's user avatar
  • 1,367
2 votes
0 answers
2k views

Difference in time format in json in mockmvc tests between SpringBootTest and WebMvcTest

I'm testing a REST controller in Spring Boot with mockMvc. One of the request parameters has a property of type OffsetTime. When I use the following annotations: @ExtendWith(SpringExtension.class) @...
Greg's user avatar
  • 1,367
1 vote
1 answer
5k views

Handling Daylight Saving Time with OffsetDateTime in Java when time needs to remain the same in local time regardless of DST

I'm using Spring Boot (Java 8) to develop the backend for a restaurant app which exposes some REST APIs. Everything related to dates and times is handled with OffsetDateTime objects and through the ...
Marcello's user avatar
  • 201
1 vote
0 answers
117 views

OffsetDateTime java8 ojdbc8 oracle insert cet to cest problem

Hello I have a problem with insert OffsetdateTime with correct timezone I have string 20110401000000000 then I do convertion to OffsetDateTime like this: DateTimeFormatter dft = ...
M.B's user avatar
  • 144
0 votes
2 answers
276 views

OffsetDateTime customer parser [duplicate]

Hello I try parse String 20110330174824917 to OffsetDateTime using DateTimeFormatter so public static void main(String[] args) { // System.out.println(OffsetDateTime.parse("...
M.B's user avatar
  • 144
0 votes
1 answer
1k views

Java OffsetDateTime.parse() adds extra zeros to time

This following codes return an OffsetDateTime like this 2021-06-30T23:59:59.009966667Z, with 2 extra zeros added. I have 7 n's in the formatter, but it still returns 9 digits. Why? import java.time....
Nancy Schroepfer's user avatar
3 votes
1 answer
5k views

How to make Spring Kafka JsonDeserializer retain the timezone offset when deserializing to OffsetDateTime

I have a message being received through Kafka, which I know has a non-UTC timezone in it. When I use the org.apache.kafka.common.serialization.StringDeserializer to verify this I get the right ...
jbx's user avatar
  • 22.1k
2 votes
2 answers
3k views

Kotlin DateTimeParseException

Getting date from https://api.spacexdata.com/v3/launches This date have format: 2006-03-25T10:30:00+12:00. I want convert it to "dd, mm, yyyy", but always getting error: "java.time....
bboy's user avatar
  • 65
1 vote
2 answers
218 views

DateTimeFormatter issue

See the following test code (java 11): public static final String DATE_FORMAT_TIMESTAMP = "YYYY-MM-dd'T'HH:mm:ss'Z'"; ... var timestamp = OffsetDateTime.now(); System.out.println(timestamp); ...
Rason's user avatar
  • 41
3 votes
2 answers
11k views

Java and Oracle timestamp with time zone

I'm trying to save two dates in Oracle with hibernate. both dates have the same timestamps in the moscow time zone: 2005-10-30T02:00+03:00[Europe/Moscow] and 2005-10-30T02:00+04:00[Europe/Moscow] (&...
AVANG's user avatar
  • 121
2 votes
1 answer
2k views

How To Parse OffsetDateTime From Csv File

I am trying to use opencsv to parse a csv file like this: 2020-09-18 06:50:00.000000 I am trying to add the parsed data following this tutorial: https://attacomsian.com/blog/spring-boot-upload-parse-...
Vincent BDL's user avatar
7 votes
4 answers
2k views

Are time zone designators- "T" and "Z" case sensitive in ISO8601 format?

I am using following ISO8601 format: YYYY-MM-DDThh:mm:ssZ And I used OffsetDateTime.parse() to parse this format. I was able to parse date-time by passing t (instead of T) and z (instead of Z) here. ...
Aishwer Sharma's user avatar
3 votes
1 answer
5k views

OffsetDateTime formatting and parsing

This code String formattedDate = OffsetDateTime.now().format(DateTimeFormatter.ISO_OFFSET_DATE); OffsetDateTime.parse(formattedDate, DateTimeFormatter.ISO_OFFSET_DATE); leads to java.time.format....
Buka's user avatar
  • 236