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.

656 questions
-2
votes
1 answer

check localdate in Java

I receive a date that i want to check if it is not in the right format (dd/MM/YYYY), I add an error to display, knowing my date is of type localDate. I found a lot of code to how to validate string dates but not localdate, if any one has an…
maya
  • 159
  • 1
  • 12
-2
votes
3 answers

LocalDate.parse(String, formatter) return wrong format

I have to query a DB for a date, then use LocalDate and a formatter to visualize in a different format. The problem is, no matter how many different formats i try, the query get visualized in the JDBC default format (yyyy-mm-dd). Please note, the…
EllC01
  • 1
  • 1
  • 1
-2
votes
2 answers

Getting null value for days calculated / added current date plus the user entered value

Getting null value for days calculated / added current date plus the user entered value We are calculating a column value based on the user entered value ie Number of days entered by the User plus the current date. private Date…
-2
votes
1 answer

How to Mock/Assign LocalDate variable in Unit Test in Java

I have a LocalDate variable which is populated from configuration properties. I need to do testing on a method which uses this variable. But it throws the error LocalDate cannot be mocked. I went through various articles in Stack Overflow and other…
smilu
  • 859
  • 7
  • 30
  • 53
-2
votes
1 answer

How to convert DateTime of jodatime into LocalDateTime of java

I tried this: LocalDateTime.ofInstant(dateTime.toInstant(), ZoneId.systemDefault())) But it gives compile time error: The method ofInstant(java.time.Instant, java.time.ZoneId) in the type LocalDateTime is not applicable for the arguments…
Jayram Kumar
  • 682
  • 2
  • 16
  • 28
-2
votes
1 answer

Formatting LocalDate in Java

I defined the following format in Java : //define format of YYYYMMDD private final DateTimeFormatter dtf = DateTimeFormatter.BASIC_ISO_DATE; My application fetches a certain date from the calendar: LocalDate localDate = fetchDate(); // fetch date…
Jadenkun
  • 317
  • 2
  • 16
-2
votes
1 answer

LocalDate and LocalDateTime depend on ZonedDateTime

Why are the methods: public ZonedDateTime atStartOfDay(ZoneId zone) from class LocalDate and public ZonedDateTime atZone(ZoneId zone) from class LocalDateTime adding dependencies to ZonedDateTime? They look like "util" methods from ZonedDateTime and…
fidudidu
  • 399
  • 3
  • 10
-2
votes
1 answer

DateFormatter ofPattern not returning the correct date

I am using DateTimeFormatter to format my LocalDate which has the value 31 Jan 2019. When I execute the code below, the correct date is returned: // 31, Dec,…
Arty
  • 819
  • 3
  • 13
  • 24
-2
votes
1 answer

Subtract two dates in dd-MMM-yy HH:mm format

The date looks like: 25/apr/18 10:24 AM Here's the code I'm trying to use DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MMM-yy HH:mm"); LocalDate open = LocalDate.parse(openTime.toString(), dtf); LocalDate now = LocalDate.now(); now =…
A_Elric
  • 3,508
  • 13
  • 52
  • 85
-2
votes
1 answer

LocalDate.parse (Not Working)

Please! I would like to understand why this simple LocalDate parsing isn't working! My DateFormatter works (in both ways), but when I'm trying to parse into a new LocalDate variable (using the same Formatter), it doesn't work and I get the following…
Erick Cabral
  • 141
  • 2
  • 7
-2
votes
1 answer

How to correctly parse to LocalDate from String in Java?

I faced a strange issue. I can't parse String value to LocalDate. The problem is that in runtime I paused at breakpoint and execute parsing in evaluate expression tool and it works. But then I continue application and I get an exception with next…
-2
votes
2 answers

How to know the number of days between 2 dates in java?

I'm trying to calculate the difference between two dates in java. For example, I have: LocalDate TodayDate = LocalDate.now(); //That returns me ==> year/month/day LocalDate ExpireDay = LocalDate.of("2018-01-12"); I want to know how many days are…
-2
votes
1 answer

Convert LocalTime for given zone to unix epoch seconds without the date component in java

We received time as hour =11, minutes=29,seconds=54,milliseonds=999 along with timezone information. How to convert this time to unix epoch milliseconds with no date part. I have tried this code : ZoneId zoneId = ZoneId.of("America/New_York"); …
RGoyal
  • 165
  • 3
  • 16
-2
votes
2 answers

Save java.time.LocalDate in Date column of DB2 database

How to persist an item of java.time.LocalDate in a column of type Date within a DB2 database ?
Ghassen
  • 591
  • 1
  • 15
  • 33
-2
votes
1 answer

How to convert String to LocalDate format without using any formatter and string methods

String value="2017/3/4"; I want my string value in LocalDate format like "2017-03-04" How to convert this value to my localdate without using any formatter and string methods like split(),indexof().
Tamil.S
  • 403
  • 3
  • 14