Questions tagged [java-time]
The java.time package is a modern date-time framework that debuted in Java 8, defined by JSR 310, supplanting the java.util.Date and .Calendar classes. Inspired by Joda-Time, but re-architected. It uses the ISO 8601 standard as the default for parsing and generating strings and includes classes to represent date-only, time-of-day-only, and span-of-time values.
java-time
1,822
questions
3
votes
1
answer
31
views
How to get Java 8 time classes to work on Jersey Jax-RS clients?
You can tell how to configure ObjectMapper to automatically handle LocalDateTime class covered here:
serialize/deserialize java 8 java.time with Jackson JSON mapper
But when I try to use POJOs with ...
-1
votes
1
answer
102
views
Changing time zone doesn't make LocalTime.now() returns different value, why?
Recently I created a VM on Google Cloud Platform to run my .jar 24/7, and a part of my code is like:
if (LocalTime.now().getHour() == 0)
whenDateChanged();
I noticed that it runs at 12 am UTC+0, ...
-1
votes
2
answers
112
views
Exception in thread "main" java.time.format.DateTimeParseException: Text 'Apr 1 2022 12:00:00:000AM' could not be parsed at index 19
I've date format like Apr 1 2022 12:00:00:000AM and looking to convert it into 20220401 (yyyyMMdd).How can we convert the Date format
import java.time.LocalDateTime;
import java.time.format....
3
votes
2
answers
82
views
How to use the Instant Class in Java to get Elapsed Time in Seconds to a Certain Number of Decimal Points? [closed]
Is there any way to use the Instant class in Java to get elapsed time in seconds to a certain number of decimal points? I took some time to experiment, and I was able to to use the .now() method at ...
1
vote
1
answer
80
views
Java Time: plus days on UTC date/time changes the hour
Consider the following:
import java.time.*;
var today = Instant.now();
var futureDay1 = today.atZone(ZoneId.systemDefault()).plusDays(1428826726);
var futureDay2 = today.atZone(ZoneOffset.UTC)....
1
vote
2
answers
66
views
Which datatype to use at JPA entity to store and retrieve date using java 8
I am using java 8 version in my application, I have confused to use java date classes like java.util.Date and java.time.LocalDate at entity and dto level.
Before java 8, we used to use either java.sql....
1
vote
1
answer
90
views
Why is java.sql’s Timestamp.of() converting incorrectly from java.time’s LocalDateTime?
I ran into a bug where java.sql's
Timestamp.valueOf(LocalDateTime.MIN())
is converting incorrectly.
Given java.time's
LocalDateTime.MIN() = -999999999-01-01T00:00:00
But when I try to convert it ...
1
vote
1
answer
25
views
Swagger Implementation for LocalDateTime type
I want to create a model class that contains createdDate feild type as LocalDateTime using swagger contract, when implementing using swagger contract it is generating offsetDateTime as type in dto.
...
1
vote
1
answer
63
views
How to make hours optional in ISO_LOCAL_TIME formatter
I'm trying to make the hours 1 or two digits and optional by modifying the ISO_LOCAL_TIME formatter. This is for parsing durations where hours can be optional. This is what I tried.
new ...
2
votes
1
answer
46
views
Bind saved Date in Edit Form using Angular 17
I have a form where the date is entered and saved but the date is not binded when I go to edit the form.
JSON:
"checkOut": {
"runDate": "2024-07-05T09:42:00.000Z",
}
...
0
votes
1
answer
42
views
Spring Boot and Batch Processor Item Date field is null
Spring batch using JdbcCursorItemReader for reader. and
.setSql("select * from EMPLOYEE")
Employee entity has a Date filed
@Column(name = "CREATE_DATE_TIME")
private LocalDateTime ...
0
votes
1
answer
46
views
Spring getting validation error with pattern dd-MM-yyyy
I have a LocalDate field of an entiry class as below.
@DateTimeFormat (pattern="dd-MM-YYYY")
private LocalDate myDate;
I have a Date object when printed displays Thu Jul 07 00:00:00 IST ...
0
votes
1
answer
52
views
Are there tools like Jqwik for easily testing Google API's time class? (DateTime, EventDateTime...etc)
I was working on implementing test code for Google Calendar-related logic and came across a library called Fixture Monkey. To briefly explain, Fixture Monkey is a library that facilitates the creation ...
0
votes
1
answer
32
views
Using LocalDateTime in Java Spring framework, still gives Date,parse() error for MongoDb collection
I want to generate a listing report based on "listing status" and "createdOn" date on the MongoDB collection"processing-status". The "listingStatus" field ...
0
votes
0
answers
88
views
java.util.Date converted to LocalDate returns Strange results [duplicate]
Date date = new Date();
Calendar cal1 = Calendar.getInstance();
cal1.set(Calendar.YEAR, 0001);
cal1.set(Calendar.DAY_OF_MONTH, 1);
cal1.set(Calendar.MONTH, Calendar.JANUARY);
cal1....