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
11
votes
1 answer

Spring Boot: Java 8 date/time type `java.time.OffsetDateTime` not supported by default

I have added the JavaTimeModule but still not able to get OffsetDateTime working on getting some data from RethinkDB @Configuration public class JacksonOffsetDateTimeMapper{ @Bean @Primary public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder…
Nderim Bytyqi
  • 111
  • 1
  • 1
  • 3
10
votes
5 answers

Jackson deserialization issue for ZonedDateTime

I've the following field in a class I use during deserialization of a service that I'm consuming. private ZonedDateTime transactionDateTime; The service I'm consuming may return a Date or DateTime using the pattern: yyyy-MM-dd'T'HH:mm:ss.SSSZ Let…
Alper Kanat
  • 376
  • 1
  • 2
  • 16
9
votes
4 answers

Can't serialize java.time.LocalDate as a String with Jackson

I am using spring-boot 1.2.1.RELEASE with jackson 2.6.2 including the jsr310 datatype. I am using the annotation @SpringBootApplication to kick off my Spring app. I have spring.jackson.serialization.write_dates_as_timestamps = false set in my…
crowmagnumb
  • 6,621
  • 9
  • 33
  • 42
8
votes
1 answer

Java 8 Exception: com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer has no default (no arg) constructor

I have a model class that has a field: @JsonDeserialize(using = InstantDeserializer.class) @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ") private OffsetDateTime offsetDt; When a request of this model is sent to the server, my controller…
jlp
  • 1,656
  • 6
  • 33
  • 48
8
votes
2 answers

java.time.LocalDate not supported in native queries by latest Spring Data/Hibernate?

Problem: Native queries with Spring Data returning dates return java.sql.Date not java.time.LocalDate, despite the setup. Context: A new project with Spring Boot 2.0.0.M5 (the latest), Hibernate 5.2.11, Hibernate-Java8 5.2.12 (which gives support…
8
votes
2 answers

Jackson (de)serialization of Java8 date/time by a JAX-RS client

I'm making a serivce client for a REST endpoint, using a JAX-RS client for the HTTP requests and Jackson to (de)serialize JSON entities. In order to handle JSR-310 (Java8) date/time objects I added the…
Rinke
  • 6,095
  • 4
  • 38
  • 55
8
votes
1 answer

Comparing ThreeTen backport to JSR-310

For some reasons, we can't use java 8 right now - we're still stuck at java 7. However, I'd like to use the new JSR-310 date/time APIs right now, using the official backport ThreeTen. Its homepage states: The backport is NOT an implementation of…
MRalwasser
  • 15,605
  • 15
  • 101
  • 147
7
votes
3 answers

LocalDate: equals vs isEqual

LocalDate in Java has two similar methods equals and isEqual. What's the difference between them? When do they output different results?
AlexElin
  • 1,044
  • 14
  • 23
7
votes
2 answers

Is there a equivalent to ChronoUnit.between that returns fraction instead of integer?

Methods such is ChronoUnit.HOURS.between(start, end) returns long so I can't get the fraction from there. Is there an alternative method/approach that would return a fraction?
jellyfication
  • 1,595
  • 1
  • 16
  • 37
7
votes
1 answer

How can I bind a form parameter to a Java 8 Duration using Spring MVC?

I know I can bind a Spring MVC form bean to a LocalDateTime using: @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) private LocalDateTime startTime; This will convert a String like 2016-01-11T15:05:05.123Z to a LocalDateTime object. I have found…
Wim Deblauwe
  • 25,113
  • 20
  • 133
  • 211
7
votes
2 answers

Period with hours, minutes and seconds

I have need for an interval data type representing years, months, weeks, days, hours, minutes, seconds. The first three (years, months, days) can be done with Period and the last three (hours, minutes, seconds) can be done with Duration however none…
Philippe Marschall
  • 4,452
  • 1
  • 34
  • 52
6
votes
0 answers

ZonedDateTime ISO-8601 parsing: why is colon in timezone ID required?

I have the following tests. @Test void withoutColon_fails() { ZonedDateTime.parse("2019-01-24T12:10:58.036820+0400"); } @Test void withColon_ok() { ZonedDateTime.parse("2019-01-24T12:10:58.036820+04:00"); } The only difference between the…
Roman Puchkovskiy
  • 11,415
  • 5
  • 36
  • 72
6
votes
1 answer

How to ignore java.time package in Android Studio

I am currently working on an Android Studio project with a minimum API version of 17 (JellyBean), so I cannot use the java.time package. Instead, I am using the ThreeTen backport for Android (com.jakewharton.threetenabp:threetenabp:1.1.0). My…
Leo Aso
  • 11,898
  • 3
  • 25
  • 46
6
votes
2 answers

Using Jersey client, problems with Java 8 Date API (Jsr310)

I'm doing a little PoC using jersey client to consume a REST service and I'm having problems with a field that is in LocalDateTime format. The REST service response is like this: { "id": 12, "infoText": "Info 1234", "creationDateTime":…
edwise
  • 869
  • 2
  • 9
  • 18
5
votes
1 answer

What are the use cases justifying the 310 OffsetDate type?

OffsetDate represents a date with a zone offset. I don't understand the purpose this class serves, what are the main use cases justifying its existence?
Brian Harris
  • 2,735
  • 3
  • 22
  • 34