Questions tagged [jsr310]

JSR 310: Date and Time API in Java JDK 8. Please use the [java-time] tag for questions relating to date & time in Java SE 8.

JSR 310 is the new date and time API added to Java JDK 8 using the package name java.time. More information, backport and related projects are available at the ThreeTen home page.

  • Please avoid using this tag moving forwards
  • Use the tag for questions relating to date & time in Java SE 8
  • Use the tag for questions relating to the backport to Java SE 7
111 questions
1
vote
2 answers

JSR 310: Converting between time zones

Trying to use JSR 310 to convert milliseconds datetime values between timezones. Dealing with milliseconds values is required, to work with legacy APIs. In my case, it's between local and UTC/GMT, but I would expect it to be the exact same code…
Sebastien Diot
  • 7,183
  • 6
  • 43
  • 85
1
vote
1 answer

Is it possible to change the base millisecond reference time from 1970 to 2008 in Java (like JSR-310)

I want to be able to change the base millisecond reference from 1970 to 2008 in Java so that I can save space in the database and unique Ids. Preferably with Joda-Time. The upcoming jsr-310 in the supposed Java 7 release implements it. In the The…
Daxon
  • 1,397
  • 2
  • 21
  • 38
1
vote
2 answers

"last Friday the 13th" in jsr310 or joda-time

I'm trying to resolve the expression "last Friday the 13th" in jsr310, though if you can do it in Joda Time or some other library, that would be fine too. I got this far: val builder = new DateTimeBuilder() .addFieldValue(ChronoField.DAY_OF_MONTH,…
Steve
  • 3,038
  • 2
  • 27
  • 46
0
votes
1 answer

JSR310 when to use which classes?

I would like to verify if my understanding of JSR310 classes use-cases are correct, below a diagram with classes, and how i see them fit: Database (UTC) || \/ OffsetDateTime (used in persistence or transmission, databases and…
dotmindlabs
  • 778
  • 1
  • 12
  • 35
0
votes
1 answer

How to serialize Java8 LocalDateTime to json as calendar object using Jackson

Im using jackson-datatype-jsr310 module, which supports LocalDateTime serialization. but by default, it serializes date/time as "[2022,6,29,17,15,54]". But I need to override this behaviour to serialize/deserialize it in "Calendar" format, ex. as…
0
votes
1 answer

@Cacheable annotation cannot work as expected when deserialize beans with LocalDateTime type property

I found that the annotation @Cacheable cannot work when the method returns a Java Bean type, this is the complete description: I annotated @Cacheable on a method to use spring cache: @Cacheable(cacheNames="userCache", key="#userId") public User…
0
votes
3 answers

Modifiying time in LocalTimeDate object

Given a LocalDateTime object in Java. How do I set the time for this to 00:00:00 ? One way is to create a new LocalDateTime object with the same date as this one and set it to 0. Is there another way to do it?
joseph
  • 147
  • 7
0
votes
2 answers

SQL Server type to generate Instant in Mybatis Generator

I want to define columns in SQL Server in order for Mybatis Generator to generate java.time.Instant or java.time.OffsetDateTime. According to Mybatis Generator Core, columns with type TIMESTAMP_WITH_TIMEZONE are mapped to OffsetDateTime when…
usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305
0
votes
3 answers

How to implement Java 8 LocalTimeDeserializer?

I have been looking for implementing a custom deserializer using LocalTimeDeserializer class of Jackson API. However, I am getting below error while actually deserializing properties using this…
0
votes
3 answers

How to parse JSR-310 date to Instant?

I'm trying to parse lets say "2020-01-12+01:00" with JSR-310 time. I read it via DateTimeFormatter.ofPattern("yyyy-MM-ddVV"), however now if I want to transform that into a Instant via…
urSus
  • 12,492
  • 12
  • 69
  • 89
0
votes
1 answer

How to use Jackson DataType: JSR310 Deser standalone?

I'm in a scenario where I'm converting from type A to type B. Type A has a date field which is of type YearMonth, and type B's date field is a String. I don't want to reinvent the wheel, so it'd be great if I could use The Jackson DataType JSR310…
Ozymandias
  • 2,533
  • 29
  • 33
0
votes
1 answer

java.time not properly deserialised using jackson

Based on what's described here, I should be serialising ZonedDateTime object using the JSR-310 representation rather than the numeric one. However, I'm getting the numeric representation. What could be the problem? This is how I configure the mapper…
JaviOverflow
  • 1,434
  • 2
  • 14
  • 31
0
votes
3 answers

Jackson Data Binding for LocalDate[] using annotation

I am converting a JSON file into Java object using Jackson with Java 8 Module. But while converting JSON array to LocalDate[] application is throwing an exception. How to convert below JSON array to LocalDate[] using annotations? JSON { "skip":…
0
votes
0 answers

Jackson ZonedDateTime serialization one time Z one time +02:00

Hello I'm using jackson 2.8.8 with jackson-datatype-jsr310 extension. I notice that one time date time is serialized into: "transactionDateTime" : "2017-06-13T16:21:40.123Z" but another time into: "transactionDateTime" :…
pustypawel
  • 331
  • 2
  • 17
0
votes
0 answers

Is there a version of restlet.ext.jackson to parse jsr310 LocalDateTime?

Wondering if there is a way to make restlet jackson extension to parse jsr310 LocalDateTime? At the moment it (version 2.3.9 of RESTlet) throws this exception: ... com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found…
seninp
  • 712
  • 1
  • 6
  • 23