59 questions
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 ...
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.
...
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 ...
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 ...
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, ...
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....
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. ...
-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 ...
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 ...
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 ...
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 (...
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....
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))
...
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....
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-...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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....
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....
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 ...
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....
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-...
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 ...
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 ...
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 ...
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 ...
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 ...
-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 ...
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 ...
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())....
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 ...
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 ...
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 ...
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&...
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)
@...
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 ...
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 =
...
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("...
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....
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 ...
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....
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);
...
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] (&...
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-...
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.
...
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....