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

Conflict between Swagger2 and jackson-datatype-jsr310 in Spring Boot application

I am creating a REST API using Spring Boot and have issues serialising LocalDateTime when I use Swagger 2. Without Swagger the JSON output is like this: { "id": 1, ... "creationTimestamp": "2018-08-01T15:39:09.819" } And with…
rafaborrego
  • 610
  • 1
  • 8
  • 19
2
votes
0 answers

Elasticsearch 6.3: why DateHistogramAggregationBuilder doesn't support JSR-310?

In ES 6.3 DateHistogramAggregationBuilder seems to only support joda DateTimeZone and not JSR-310 ZoneId. Am I missing something ? (I used to use DateHistogramBuilder which support java ZoneId but that class is no longer available)
Gustavo
  • 526
  • 1
  • 4
  • 13
2
votes
1 answer

Java new time API compiles and break at run time

I am trying to use consistently the Java 8 date time API, I am looking for explications behind this behaviour : Instant.from(LocalDateTime.of(2017,01,01,0,0,0,0)) Compiles just fine but yields to : Exception in thread "main"…
Antonin
  • 879
  • 2
  • 10
  • 27
2
votes
1 answer

Spring Boot Jackson JSR-310 - ZonedDateTime always timestamp

Consider this Spring MVC controller started using Spring Boot: @RequestMapping("/foo") public Foo get() { return new Foo(); } public class Foo { @Getter @Setter private ZonedDateTime time = ZonedDateTime.now(); } I want to…
jantobola
  • 688
  • 2
  • 10
  • 28
2
votes
1 answer

converting ZonedDateTime to Calendar using ThreeTen-Backport (JSR 310)

I am trying to convert a ZonedDateTime object to a Calendar object using the back-port of the java.time classes (JSR 310): the ThreeTen-Backport project. My understanding was that the back-port was supposed to be similar to functionality on Java 8…
Casey Harrils
  • 2,793
  • 12
  • 52
  • 93
2
votes
3 answers

How to make a method generic to work with LocalDate and LocalDateTime?

I have a Java method as below: private static boolean isDateBetweenRange(DataSet obj, MyClass dataSource, ConditionContext context) { FilterContext fc = dataSource.getData(); LocalDate dateFieldToCheck =…
Ajeetkumar
  • 1,271
  • 7
  • 16
  • 34
2
votes
1 answer

Deserializing property LocalDate with swagger and jax-rs

I am getting the following error from my REST interface: Problem deserializing property 'calculationStartDate' (expected type: [simple type, class java.time.LocalDate]; actual type: org.joda.time.LocalDate) This is very strange, because I am…
Martijn Burger
  • 7,315
  • 8
  • 54
  • 94
2
votes
1 answer

Spring DateTimeFormat Configuration for java.time

I'm working on a Spring WebMvc (not Spring Boot) project that uses pure Java configuration for setting up its beans. I am having difficulty getting Spring/Jackson to respect the @DateTimeFormat annotation with java.time (jsr310) objects such as…
Alex
  • 392
  • 4
  • 17
2
votes
1 answer

Formatting java.time (jsr310) objects in Grails 3 JSON / rest-api

Trying to use the java.time API in Grails 3.1.x rest controllers. My domain object "Absence" has a field LocalDate date build.gradle contains compile "org.jadira.usertype:usertype.extended:5.0.0.GA" as a dependency and application.groovy…
runeaen
  • 461
  • 5
  • 22
2
votes
3 answers

Java 8 DateTime serialization and Jackson JSR 310

I am using Java 8 DateTime and Jackson jsr 310 support in a Spring Boot application. I disabled SerializationFeature.WRITE_DATES_AS_TIMESTAMPS to force Jackson to serialize the localDatetime to string instead of int array. But I found a weird…
Hantsy
  • 8,006
  • 7
  • 64
  • 109
2
votes
1 answer

ThreeTen-Backport implementation vs. backport of JSR-310?

Note: this is not a duplicate of Comparing ThreeTen backport to JSR-310. My question is more specific. In my company, I'm trying to get DevOps to O.K. the use of ThreeTen-Backport for refactoring legacy code (which because of deployment constraints…
James Dunn
  • 8,064
  • 13
  • 53
  • 87
2
votes
2 answers

Create a JSR 310 Clock based on UTC instead of local time?

EDIT: OK. I unfortunately have to admit my understanding of Java time was crucially flawed, making this question meaningless. I always thought that System.currentTimeMillis() returned the local time. Why? Because when you create a Date with it, it…
Sebastien Diot
  • 7,183
  • 6
  • 43
  • 85
2
votes
2 answers

Java jsr310: difference between dates and times

There are a plethora of SO questions that deal with calculating the difference between two dates or two times in Java. Many answers point out the problems with the core Java Date classes, and suggest using Jodatime, but AFAIK, there are none that…
amaidment
  • 6,942
  • 5
  • 52
  • 88
1
vote
2 answers

How can I plug my own TZ data?

I've seen ResourceZoneRulesDataProvider which loads the TZ data via ClassLoader.getResource. But how can I instruct ThreeTen to load my own TZ data instead, say from a shared file system unrelated to my app's CLASSPATH?
Brian Harris
  • 2,735
  • 3
  • 22
  • 34
1
vote
1 answer

Ending 0's are getting truncated from millisecond part of ZonedDateTime object in Java11

I am upgrading my spring boot application to spring boot 2.7.8 and Java 11. I getting different rest response of ZonedDateTime object after upgrade. My request contain "2023-06-23T18:13:06.630Z[UTC]", and I am returning same request object as a Map…