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

Jackson ObjectMapper.findAndRegisterModules() not working to serialise LocalDateTime

I am using Java Spring-boot RestController. I have a sample GET API in which I am sending LocalDateTime.now() in response body. I have customised the Jackson ObjectMapper to register jackson-datatype-jsr310 module, However it fails to serialise the…
1
vote
0 answers

Jackson LocalDate deserialization error only in release-APK

I have an Android App, which receives data via an JSON Api. I then convert the data with Jackson ObjectMapper. I also included com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.0 in my build.gradle to ensure LocalDates are handled…
Sunchezz
  • 740
  • 6
  • 21
1
vote
1 answer

DateTimeFormatterBuilder with default zone id?

I have a requirement where if ISO date time does not specify zone offset, I should assume Europe/Bratislava's current offset. Basically "2020-03-26T22:47:32.497" -> "2020-03-26T22:47:32.497+01:00" Tldr; do parse time zone id if there is one, but…
urSus
  • 12,492
  • 12
  • 69
  • 89
1
vote
1 answer

How to deserialize dates with offset ("2019-01-29+01:00") to `java.time` related classes?

I've refactored some legacy code within Spring Boot (2.1.2) system and migrated from java.util.Date to java.time based classes (jsr310). The system expects the dates in a ISO8601 formated string, whereas some are complete timestamps with time…
rene
  • 1,618
  • 21
  • 26
1
vote
0 answers

best practice to set the formatter of LocalTime to ISO

After searching and looking in spring source code, I found I can configure application-wide default LocalTime formatter (mainly for use in Request Parameters) in one of two ways (both by subclasses for WebMvcConfigurer: @Override public void…
Muhammad Hewedy
  • 29,102
  • 44
  • 127
  • 219
1
vote
2 answers

Java ZonedDateTime and British Summer Time

I am currently looking at ZonedDateTime behaviour when the date is inside and outside British Summer Time. The British Summer Time starts on 25th of March and it adds one hour (+1). I have created few instances of ZonedDateTime (UTC and…
Taks
  • 2,033
  • 4
  • 18
  • 23
1
vote
1 answer

How to set date format for JsonObjectMapper in Spring Integration

I am converting my Java object to Map using Spring Integration ObjectToMapTransformer's transformPayload(). Everything works fine except that the Instant fields in my object are getting broken into epochSecond and nano, which in turn throws…
Vikas Prasad
  • 3,163
  • 5
  • 28
  • 39
1
vote
1 answer

JPA-QL query find all entities with LocalDateTime timestamp between LocalDate startDate and LocalDate endDate

I have a JPA entity TimeSlot with a LocalDateTime field called startDateTime: @Entity public class TimeSlot { private LocalDateTime startDateTime; ... } I am using Hibernate on WildFly 10.1. How do I query all entities with the…
Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
1
vote
1 answer

Working with Java 8 Date/Time API in Spring Boot

I'm working with Java 8 Date/Time API (JSR-310) on a brand new Spring Boot (1.5) application. Prior the first public release we can stay on tip of every dependencies and that's why I want to clarify the state of JSR-310 handling on the complete…
LeRiton
  • 313
  • 1
  • 4
  • 10
1
vote
1 answer

Why does joda time update the time and offset when java time doesn't?

I can't seem to figure out why joda time is updating the time and offset hours after daylight saving time, but java time doesn't. DateTime dateTime = new DateTime("2016-04-05T10:06:21.636-05:00").withDayOfWeek(5); TemporalField dayOfWeek =…
Jon
  • 453
  • 5
  • 18
1
vote
1 answer

Why is withWeekOfWeekyear giving me a different offset?

I'm trying to convert withWeekOfWeekyear over to java.time. I can't seem to figure out why I'm getting a different offset with withWeekOfWeekyear compared to weekOfWeekBasedYear. DateTime dateTimeWeek = new DateTime().withWeekOfWeekyear(1); …
Jon
  • 453
  • 5
  • 18
1
vote
2 answers

How to do strict LocalDate parsing in js-joda?

I'm trying to parse a LocalDate from a String using strict resolution in js-joda (version 1.1.1). I don't want to accept inputs that aren't valid dates, like 2016-05-32. But I just don't get it. My code is: formatter = (new…
Tobías
  • 6,142
  • 4
  • 36
  • 62
1
vote
1 answer

How can I deserialize java.time.LocalDate in Spring HATEOAS?

I am building a Spring HATEOAS application. When I POST a JSON document containing ISO8601 dates I get: Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Text…
Orestis
  • 36
  • 6
1
vote
0 answers

Neo4jTemplate save not saving Java 8 LocalDateTime field

I am using spring-boot with spring-data-neo4j-rest. Maven dependencies are as org.springframework.boot spring-boot-starter-web
Shikha Gupta
  • 103
  • 1
  • 7
1
vote
4 answers

How can I change Jacksons Configuration when using Spring Data REST?

I'm trying to configure Jackson to show JSR 310 instants in ISO 8601 format. @Configuration class Jackson { @Bean static ObjectMapper objectMapper() { ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules(); …
xenoterracide
  • 16,274
  • 24
  • 118
  • 243