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
3
votes
2 answers

JSR310 How to internationalize a pattern for a month-day?

Im trying to format a date without a year (just day and month, e.g 12.10) DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT) still yield year for me (12.10.20). so I tried DateTimeFormatter.ofPattern("dd. MM") but that obviously hardcodes order…
urSus
  • 12,492
  • 12
  • 69
  • 89
3
votes
1 answer

Jooq LocalDateTime fields use system timezone instead of session timezone

I'm using jooq (v3.11.9) to access a MySQL database that is running in UTC time. I've using generated entities and am using JSR-310 time types. The option I'm using in my config: true My understanding is that the…
lights
  • 1,034
  • 1
  • 8
  • 22
3
votes
1 answer

Serialize LocalDateTime with only milliseconds with Jackson

I want to serialize a LocalDateTime to textual format while only showing milliseconds. I tried the following example: final ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new Jdk8Module()); mapper.registerModule(new…
TheBrizzler
  • 33
  • 1
  • 3
3
votes
3 answers

JJWT / Jackson alter the ObjectMapper used

For a project I am working on, I am required to use Spring Security and JSON Webtokens as provided by the library io.jsonwebtoken (jjwt). One of the claims I am required to add to my generated token is the following entity (simplified to illustrate…
Pieter De Clercq
  • 1,951
  • 1
  • 17
  • 29
3
votes
1 answer

Serialize Date, Instant to ISO 8601 when using JSR310 java.time in spring

I am replacing JodaTime by JSR310 and the module of JodaTime() was working fine. I am trying to reconfigure the serialization of my dates in my spring-boot application. I can't keep both so I am looking for a way to serialize/deserialize my date to…
Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204
3
votes
0 answers

How can I serialize/deserialize JSR310 classes using json4s and Jackson?

I have a case class: case class Stuff(createdOn: Instant) and I'm using json4s with Jackson to provide my JSON serialization/deserialization. However, I'm not able to serialize/deserialize createdOn properly. If I was using plain Jackson,…
manub
  • 3,990
  • 2
  • 24
  • 33
2
votes
0 answers

Querydsl`s JPASQLQuery uses java.sql.Date instead of java.time.LocalDate

I have a simple PostgreSQL table: CREATE TABLE public.test_entity ( id int8 NOT NULL, title varchar NOT NULL, created_at date NOT NULL, CONSTRAINT test_entity_pkey PRIMARY KEY (id) ); Entity for that table and…
2
votes
1 answer

InvalidDefinitionException with jackson-datatype-jsr310 version 2.12.3

I'm having an issue with the jackson jsr310 datatype using version > 2.12.0, while this works perfectly with version 2.11.4. This is my POJO: import java.time.OffsetDateTime; public class Pojo { OffsetDateTime aDateTime; public…
2
votes
1 answer

How to restrict jackson from parsing millis to LocalDate in json request

I need to validate LocalDate fields in json requests. What i want is to prevent deserializing numbers as miilis to LocalDate. Here is example: I have an entity: public class Test { @NotNull @JsonFormat(pattern = "yyyy-MM-dd") private…
Nikita
  • 35
  • 5
2
votes
1 answer

How to configure jackson-modules-java8 in Ktor

I am trying to configure jackson-modules-java8 with Ktor and Jackson but to no avail. The module is added to gradle.build dependencies { ... implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.0-rc2' …
Thomas
  • 793
  • 1
  • 8
  • 16
2
votes
1 answer

Algorithm used by java.time.Period.between() when dealing with different-length months?

When using java.time.Period.between() across months of varying lengths, why does the code below report different results depending on the direction of the operation? import java.time.LocalDate; import java.time.Period; class Main { public static…
Justin Grant
  • 44,807
  • 15
  • 124
  • 208
2
votes
1 answer

Persisting java.time.LocalTime into oracle with Types.TIME loses fractional seconds precision

I have a behavior with Oracle which I'm not sure is intended or not. I am playing with the various types of the java date/time API, using them at the JDBC level. I am trying to persist an instance of java.time.LocalTime into an oracle database. At…
jmaniquet
  • 93
  • 4
2
votes
2 answers

Zone adjustment not taken into account when parsing RFC 3339 date time

(Migrated from CodeReview) I am experimenting and trying to understand Java Time better. My code is not working as expected and I want to ask the reason, probably because there is a misunderstandment from my side about JSR-310 time zone handling. I…
usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305
2
votes
1 answer

Good design of a localized YearWeek according to JSR-310

I need an object that represents a localized concept of a seven days week. That object is pretty much the same as the YearWeek found in the ThreeTen-Extra library, except that the first day and the minimal number of days varies. I thought initially…
Marcos Passos
  • 400
  • 1
  • 3
  • 15
2
votes
1 answer

DatepickerDialog with LocalDate instead of Day Month Year

I'm trying to make a custom DatePickerDialog class that will fire the onDateSet Listener Callback, but instead of containing the "Day" "Month" and "year" values, I want to overload the constructor to contain a LocalDate from java.time instead. I…
fogx
  • 1,749
  • 2
  • 16
  • 38