141 questions
-3
votes
2
answers
181
views
Does Instant.MAX need to be manually formatted? [closed]
DateTimeFormatter fails on valid Instants. How it is meant to format those below and above LocalDateTime.MIN and LocalDateTime.MAX? Manually?
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"...
-1
votes
1
answer
183
views
how to correct convert Timestamp to Instant with UTC time zone?
I have a problem when i get a data from DB
I get data like this TIMESTAMP TIME = 2024-05-15 15:12:44.0 - Timestamp SQL (package) type
After i convert to Instant i have offset -3 hours
Like this ...
2
votes
1
answer
600
views
How can I get the maximum value for Instant#ofEpochSecond(?)
I just found that the Instant#ofEpochSecond(epochSecond) has minimum/maximum values.
Here comes the source codes.
// Instant.java
/**
* The minimum supported epoch second.
*/
private ...
2
votes
2
answers
6k
views
Unable to obtain Instant from TemporalAccessor: 2023-08-31T20:37:49.005832800 of type java.time.LocalDateTime
I am using parmeterised method for Temporal class and passing LocalDateTime to Temporal argument and getting error in Instant.from(Temporal t) method where, t instancof LocalDateTime in my case.
Here ...
0
votes
1
answer
709
views
nanoseconds difference for java.time.Instant testing
I have tests where I compare java.time.Instant dates. When I run these tests locally, everything works correctly. But remote build fails due to tests.
org.opentest4j.AssertionFailedError: expected: &...
2
votes
1
answer
435
views
java.time.Instant does not render on the consumer side
I am trying to send some information with Kafka. I have a class to handle this task. The class includes a private variable called "timestamp" of type Instant. When the timestamp is generated,...
4
votes
2
answers
2k
views
Convert timestamp with offset to UTC
Conversion
I have a timestamp with an offset (-6) in the following format:
2019-11-30T00:01:00.000-06:00
and I want to convert it to an UTC timestamp, like:
2019-11-30T06:01:00.000Z
Attempt
I tried ...
-1
votes
2
answers
778
views
Are there any annotations for resolving java.time.Instant deserialization errors. I am getting this error as I have a dateType field as Instant
Error: Java 8 date/time type** java.time.Instant** not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310
I have followed forum comments and added relevant ...
0
votes
2
answers
2k
views
Java PreparedStatement reading local timezone when using Timestamp.from(Instant)
I'm attempting to populate a UTC timestamp into a SQL table, but when I use Instant.now() to get the current UTC time, a conversion of Timestamp.from(instant) is writing local time zones into the ...
4
votes
4
answers
2k
views
Why does LocalDateTime.ofInstant() requires ZoneId
In Java,
If Instant represents a point in time, encoded as date and time in
UTC.
And LocalDateTime represents a point in time, encoded as date and time in the JVM local timezone.
Why then does ...
0
votes
2
answers
508
views
How can I add 18 as day to current month using java Instant
I can get the current date using
Instant.now()
I am looking to get 18-<current month>-<current year>
0
votes
1
answer
445
views
Why is conversion from LocalDateTime to Instant not working?
Do you know why 4. and 6. prints have wrong hours in following code?
LocalDateTime ldtNow = LocalDateTime.now();
LocalDateTime ldtNextMonth = ldtNow.plusMonths(1);
System.out.println("1. " +...
-4
votes
2
answers
150
views
Create first Instant of year 2022 [closed]
I have an int representing the year 2022, and I want to create an Instant object representing the first instant of the year, meaning: 2022-01-01 00:00:00.
int year = 2022;
Instant instant = ...
How ...
0
votes
2
answers
452
views
Different ZonedDateTime of GMT and BST become same Instant after toInstant conversion in Scala
to summarize my question, I have 2 different ZonedDateTime objects with GMT and BST but same local time. They become the same Instant values after toInstant conversion. I am expecting after conversion,...
1
vote
2
answers
5k
views
How to elegantly convert from MSSQL Datetime2 to java.time.Instant
I have a simple spring boot REST API application, using plain jdbc to fetch data from a MSSQL DB. I am trying to figure out how best to retrieve a DATETIME2 column from the DB (which stores no ...
1
vote
1
answer
1k
views
ofInstant is not a member of object java.time.LocalDate
I have following scala code:
LocalDate.ofInstant(instant, zoneId)
instant is java.time.Instant, zoneId is java.time.ZoneId.
Intellij project is configured to jdk 17 and language level to 15.
But I ...
0
votes
1
answer
967
views
Convert Java Instant to String with timezone
I have to compare a instant with a date String but format are differents.
The Instant is initiate with "now" but without "+nnnn" part (I think it's timezone).
How can I create a ...
0
votes
0
answers
332
views
My Instant.now() don't work, but when it does i get another problem
This is some basic program that I trying to build to learn some Java before I'm starting in
programming courses. I can't get the time to pulloff in the right time interval between Start = Instant.now()...
2
votes
1
answer
156
views
Hibernate not parsing values around DST transitions correctly
I've got a problem where an Instant that occurs during the DST transition is being persisted correctly to the database, but when read back is returning a different value.
Specifically, I am in Europe/...
0
votes
1
answer
909
views
how to create a Instant class variable in kotlin with my own timestamp
Till now i was using
val date = Instant.now(Clock.system(ZoneId.of("UTC")))
to generate the instant timestamp.
Now I need to substitute it with the date that I want to specify for example &...
3
votes
2
answers
2k
views
Parse string with offset to Instant Java 11
I am trying to parse the following string 2021-10-15T08:39:05+02:00 into an Instant this works seamlessly using Java 15 but throws an error for Java 11.
java.time.format.DateTimeParseException: Text '...
2
votes
3
answers
3k
views
Converting string date time with +0000 To instant
How do I convert the datetime that is passed as string 2018-08-10T18:25:00.000+0000 to a Instant? I tried the below and it did not work.
public static Instant toInstant(final String timeStr) {
if ...
10
votes
1
answer
2k
views
What is the main purpose of the new interface java.time.InstantSource over existing abstract class Clock?
A new interface java.time.InstantSource was added in Java 17. What is the use case of that additional abstraction if all implementations of that interface are Clock implementations too anyway?
2
votes
2
answers
702
views
parsing date from "06/25/2021 10:26:33.0" format to "2021-06-25T10:26:33.000-04:00" using java.time
I have to convert a date for the purpose of comparison using junit. I get a date from DB which is "06/25/2021 10:26:33.0" and I have to convert it to "2021-06-25T10:26:33.000-04:00"...
1
vote
0
answers
55
views
ZonedDateTime to Instant is right in Java 8 but off by 1h in Java 9+ [duplicate]
When running the following code in Java 8, the Instant produced from parsing the String "2021-03-26T23:43:03+01:00[Europe/London]" is "2021-03-26T23:43:03Z"
(which afaik is right ...