java-time Questions
2
Solved
I have an Instant Date, eg: 2020-03-09T20:13:57.089Z and I want to find the end of next day in Instant, eg - 2020-03-10T23:59:59.089Z (this would be the end of next day compared to the initial date...
4
Solved
So I would expect this code to work under the new Java 8 date/time package since all it does is to convert a given ZonedDateTime to string and back using the same built-in DateTimeFormatter instanc...
7
Solved
If I use java.util.Date's toInstant() on a variable which happens to be a java.sql.Date, I get an UnsupportedOperationException.
try {
java.util.Date input = new java.sql.Date(System.currentTime...
Stunk asked 17/10, 2017 at 16:20
3
Solved
In the new date package in Java 8, we changed from using "new Date()" to "LocalDate.of()".
Date d = new Date(year, month, dayOfMonth); //Old way
LocalDate d2 = LocalDate.of(year, month, dayO...
2
Solved
I have this code:
String date = "2019-04-22T00:00:00+02:00";
OffsetDateTime odt = OffsetDateTime
.parse(date, DateTimeFormatter.ISO_OFFSET_DATE_TIME)
.withOffsetSameInstant(ZoneOffset.of("+00:...
Proulx asked 20/12, 2019 at 17:46
3
Solved
Could you please shed some light on how to obtain correct epoch time in milliseconds for a default system timezone and given timezone.
Given
1. TimeZone: GMT+3
2. The following code snippet:
im...
5
Solved
I do want to check if an Instant is between two other instants:
Currently I use:
import java.time.format.DateTimeFormatter;
import java.time.Instant;
Instant start = Instant.from(DateTimeFormat...
3
Solved
I have two LocalDates declared as following:
val startDate = LocalDate.of(2019, 10, 31) // 2019-10-31
val endDate = LocalDate.of(2019, 9, 30) // 2019-09-30
Then I calculate the period between th...
Fern asked 26/10, 2019 at 18:45
1
I want to save a timestamp value into PostgreSQL database. Corresponding column is of the type TIMESTAMP WITHOUT TIME ZONE.
As input Java application gets epoch time (long value), that could be con...
Statutory asked 17/10, 2019 at 13:44
3
Given a Clock, an Instant and the current Thread, is there already some (utility) method in the Java libraries that makes the current thread sleep until the given clock reaches the instant?
Someth...
2
Solved
I investigated the DynamoDB options for storing the date and time using the Java SDK. As far as I can see, custom converters are needed for the Java8 LocalDate and LocalDateTime, while for the old ...
Pimply asked 10/11, 2017 at 8:28
4
Solved
I'm trying to parse date in ISO8601 format:
yyyy-MM-dd'T'HH:mm:ss.SSSZ
Am I correct that it is not possible to parse it with any of the default formats defined in java.time.format.DateTimeFormat...
2
Solved
Before Java 8 I was using in code new Date().getTime() to obtain current timestamp as number. Can I assume that Instant.now().toEpochMilli() is safe equivalent to the legacy way? Does it have exact...
6
Solved
Other answers here refer to Joda API.
I want to do it using java.time.
Suppose today's date is 26th Nov 2015-Thursday, when I add 2 business days to it,
I want the result as Monday 30th Nov 2015....
1
Solved
There has been changes in Java Date & Time API Since Java 9.
LocalDateTime now has microseconds precision.
Java 9 has a fresh implementation of java.time.Clock capable of capturing the curre...
Sebi asked 8/8, 2019 at 11:47
3
Solved
I have a user input field and would like to parse his date, whatever he puts in.
The user might provide his date with a leading zero or without one, so I wanna be able to parse an input like this ...
Frolic asked 7/8, 2019 at 11:54
3
Solved
Please suggest if there is an API support to determine if my time is between 2 LocalTime instances, or suggest a different approach.
I have this entity:
class Place {
LocalTime startDay;
Local...
2
Solved
Using the Java Instant class, how can I round up to the nearest second? I don't care if it is 1 millisecond, 15 milliseconds, or 999 milliseconds, all should round up to the next second with 0 mill...
2
Solved
I have a very peculiar question where I am trying to parse "2019-12-25T17:00:00-05:00"
such that it should give me the result DEC 12 | Thursday | 5:00pm
I tried the following code by using DateTi...
Overreach asked 24/7, 2019 at 1:56
3
Solved
1
Solved
I have some text that is only being parsed by a DateTimeFormatter when the parse style is Strict - and not when it's Lenient.
This seems like the opposite behaviour to what I'd expect?
Example:
...
3
It is my understanding that a ZonedDateTime is really an enhanced version of an Instant. It has all the data an Instant has (precise value along UTC timeline), plus time zone information. So my naï...
1
Solved
In the Java class java.time.Period the method normalized() has the following in its Javadoc:
This normalizes the years and months units, leaving the days unit unchanged.
The superclass' method...
2
Solved
Jooq currently does not support JSR 310 types and support will not come until v3.8.
Using simple converters generally works, except for certain types, such as postgres' TIMESTAMP WITH TIME ZONE, w...
Curler asked 16/10, 2015 at 15:9
1
Solved
These two OffsetDateTime are returning a different String representation and different offsets.
The trigger time was created in a different service, but also through OffsetDateTime.now() an...
© 2022 - 2024 — McMap. All rights reserved.