Questions tagged [localdate]

LocalDate is part of the java.time package and represents a year-month-day in the ISO calendar and is useful for representing a date without a time, such as 2000-01-01 (January 1st 2000). It can be used for storing a birth date for example.

524 questions
6
votes
1 answer

What does Java's BST ZoneId represent?

I have stored in the DB this Time Frame: any day from 15:00 to 16:00 in LONDON (BST) I need to execute a program IF when I receive an event is between this Time Frame. I am running the Test now in Paris (16:22) where in London is 15:22 (so in…
La Carbonell
  • 1,638
  • 3
  • 17
  • 47
6
votes
1 answer

LocalDate minus a Period get wrong result

LocalDate minus a Period(like "28 years, 1 months and 27 days"),get wrong result. But minus a Period(only have days unit ,like "10282"days) get right result. Is there anything to notice? public static void main(String[] args) { …
ChouChou
  • 63
  • 5
6
votes
2 answers

Java 8 LocalDate to JavaScript Date

I would like to convert this Java LocalDate to a JavaScript Date: { "date": { "year": 2016, "month": "NOVEMBER", "dayOfMonth": 15, "monthValue": 11, "dayOfWeek": "TUESDAY", "era": "CE", …
Moatez Bouhdid
  • 1,121
  • 6
  • 18
  • 41
5
votes
1 answer

Failed to convert value of type 'java.lang.String' to required type 'java.time.LocalDate';

As in topic I want to get date passed as a parameter. I've got this dependency: com.fasterxml.jackson.datatype jackson-datatype-jsr310 My URL…
pipilam
  • 507
  • 1
  • 6
  • 17
5
votes
2 answers

Find most recent date in a list of objects on LocalDate property using Java 8 stream

I have a list of objects which hold multiple properties, one of which is a LocalDate. I'd like to find the object with the most recent date out of this list. I'm fairly green with Java 8 and using streams. Like most programming, it seems as though…
acousticarmor
  • 61
  • 1
  • 6
5
votes
2 answers

How can I change the language of the months provided by LocalDate?

I need to find the current month and print it. I have the following code: this.currentDate=LocalDate.now(); this.month = this.currentDate.getMonth(); The problem is that the month is in English and I need to print it in French, to match the rest of…
shas
  • 333
  • 2
  • 17
5
votes
1 answer

How to subtract Hijrah year from a Hijrah Date in Java 8 Date API

I want to display the Ramadan 2017 start and end dates. I tried writing code using the HijrahChronology built into Java 8 and later, with HijrahDate class. import java.time.LocalDate; import java.time.chrono.HijrahDate; import…
Rahul
  • 145
  • 14
5
votes
3 answers

Java 8 LocalDateTime - How to Get All Times Between Two Dates

I want to generate a list of dates + times between two dates in the format 2018-01-31T17:20:30Z (or "yyyy-MM-dd'T'HH:mm:ss'Z'" ) in 60 second increments. So far I've been able to generate all dates between two dates using a LocalDate object: public…
David Lynch
  • 159
  • 1
  • 8
5
votes
2 answers

DateTimeFormatter.ISO_LOCAL_DATE vs DateTimeFormatter.ofPattern("yyyy-MM-dd") in Java 8+

I have a date I’ve created using ZonedDateTime.now(ZoneOffset.of("+2:00")).minusDays(5). Now I want to format it as yyyy-MM-dd. In Java 8+, is DateTimeFormatter.ISO_LOCAL_DATE the equivalent of DateTimeFormatter.ofPattern("yyyy-MM-dd")? The output…
JL Gradley
  • 1,205
  • 2
  • 11
  • 14
5
votes
3 answers

Jackson: deserialize epoch to LocalDate

I have following JSON: { "id" : "1", "birthday" : 401280850089 } And POJO class: public class FbProfile { long id; @JsonDeserialize(using = LocalDateDeserializer.class) LocalDate birthday; } I am using Jackson to do…
kpater87
  • 1,030
  • 12
  • 29
5
votes
2 answers

Spring MVC 4 + Jackson + LocalDate

I am using Spring MVC 4 with Jackson API for databinding and I am having some issues while using Java 8 Dates, like LocalDate and LocalTime. Here is my Ajax: var response = $.ajax({ url: 'parcela', method: 'POST', data: { formaPagamentoPrazo:…
4
votes
1 answer

LocalDate.EPOCH is not available

I need to normalise some Data to execute a SQL-Statement. Unfortunately I can't initialize a LocalDate-variable with LocalDate.EPOCH. MIN and MAX are working. startDatum = startDatum == null? LocalDate.EPOCH : startDatum; // doesn't work endDatum =…
Bastian
  • 59
  • 1
  • 6
4
votes
2 answers

Is it possible to simplify @JsonSerialize annotations?

The following code works fine: // works public class MyClass { @JsonSerialize(using = LocalDateTimeSerializer.class) @JsonDeserialize(using = LocalDateTimeDeserializer.class) private LocalDateTime startDate; @JsonSerialize(using =…
4
votes
7 answers

How to parse time based tokens in java ?(1m 1M 1d 1Y 1W 1S)

I gets following strings from FE: 1m 5M 3D 30m 2h 1Y 3W It corresponds to 1 minute, 5 months,3 days, 30 minutes, 2 hours, 1 year, 3 weeks. Is there mean in java to parse it? I want to manipulate(add/minus) with Instant(or LocalDatetTime). Is there…
gstackoverflow
  • 31,683
  • 83
  • 267
  • 574
4
votes
2 answers

LocalDateTime format in Spring Boot

Hey I've got the same problem as here: JSON Java 8 LocalDateTime format in Spring Boot I tried solutionts from there and it does not work. Could someone tell me what I did wrong? I…
pipilam
  • 507
  • 1
  • 6
  • 17
1 2
3
34 35