Questions tagged [offsetdatetime]
58 questions
1
vote
1 answer
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 timestamp like 1970-01-01T00:00:00.0000-00:00 and I need to…

Nico
- 49
- 5
1
vote
3 answers
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 OffsetDateTime for dateRegistered field:
public class…

pixel
- 9,653
- 16
- 82
- 149
1
vote
1 answer
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.format.annotation.DateTimeFormat.ISO.DATE_TIME)
private…

warozell
- 49
- 2
- 6
1
vote
1 answer
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 works totally fine but there are some dates in the list that…

ihaider
- 1,290
- 4
- 19
- 38
1
vote
0 answers
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 support a date time with offset…

bFren_Sakar
- 11
- 4
1
vote
1 answer
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 this date "2021-12-10T10:58:05.309594500+01:00"…

Sia
- 63
- 1
- 9
1
vote
3 answers
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 TemporalAccessor: {},ISO resolved to…

Stefan
- 444
- 5
- 16
1
vote
0 answers
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 updateDate as
List…

Vishal
- 674
- 1
- 7
- 20
1
vote
2 answers
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 keep getting this error -
org.threeten.bp.format.DateTimeParseException:…

Vaibhav
- 47
- 5
1
vote
0 answers
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)
@WebMvcTest(MyController.class)
the following…

Greg
- 1,227
- 5
- 23
- 52
1
vote
1 answer
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 app I use, by default, the offset of "Europe/Rome".…

Marcello
- 191
- 11
1
vote
0 answers
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 =
new DateTimeFormatterBuilder()
…

M.B
- 134
- 9
1
vote
2 answers
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);
var formatter =…

Rason
- 41
- 5
1
vote
1 answer
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-csv-file. This is my model:
public class MyIndPrd…

Vincent BDL
- 111
- 11
1
vote
0 answers
Spring JDBC loses offset of timestamp with timezone
I'm using Java 8 + Spring 5.1.5R + mybatis 3.5.6 with PostgreSQL 11.
I executed select query with date, timestamp, timestamptz columns like this.
SELECT t_date ,t_timestamp ,t_timestamptz FROM a_table
And I can see ibatis log like…

jaehak Lee
- 63
- 1
- 1
- 6