java-time Questions
1
Solved
I am currently working with Java's DateTimeFormatter to parse ISO 8601 formatted timestamps, particularly those containing fractional seconds. While experimenting with different timestamp formats, ...
Tother asked 3/10 at 10:26
5
Solved
I'm trying to parse a simple string in the format "YYYYww" (e.g. 201901) into a LocalDate, but none of my attempts succeed.
I attempted to parse it by simply using the pattern "YYYYww" and also th...
3
Solved
Are the both methods equivalent?
version 1:
var diff = Duration.between(begin, end).toHours();
version 2;
var diff = ChronoUnit.HOURS.between(begin, end);
Are there any implicit differences? If y...
10
I'm trying to make a method, which uses the Json data with jackson library to have a list of objects.
If I run my code, I get the error:
java.lang.reflect.InaccessibleObjectException: Unable to mak...
4
I have a localdatetime object that is in UTC. I want to convert into IST.
How can I do that?
LocalDateTime dateTimeOfAfterFiveDays = LocalDateTime.ofEpochSecond(after5,0,ZoneOffset.UTC);
3
Solved
For some unknown reason, MaterialDatePicker returns incorrect date after selection.
For example, user is in Mexico region with timezone: America/Tijuana. When he selects in visual representation: 2...
Renwick asked 20/10, 2021 at 14:58
2
Solved
Did like below,
LocalDateTime currentUTCTime = LocalDateTime.now(ZoneId.of("UTC"));
String reqPattern = currentUTCTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
System.out.pr...
2
Solved
I'm playing around with the new java.time package in Java 8. I have a legacy database that gives me java.util.Date, which I convert to Instant.
What I am trying to do is add a period of time that ...
5
Solved
I am trying to change the format of a String date from EEEE MMMM d to MM/d/yyyy by, first, converting it into a LocalDate and then applying a formatter of a different pattern to the LocalDate befor...
Cataclinal asked 26/7, 2017 at 8:6
3
Solved
I've read the documentation, but I still can't get when I should use one or the other:
OffsetDateTime
ZonedDateTime
According to documentation OffsetDateTime should be used when writing date t...
15
Solved
I am wondering if there is a way to get current milliseconds since 1-1-1970 (epoch) using the new LocalDate, LocalTime or LocalDateTime classes of Java 8.
The known way is below:
long currentMil...
Belted asked 29/5, 2014 at 22:57
8
Solved
I'm trying to format an Instant to a String using the new Java 8 Date and Time API and the following pattern:
Instant instant = ...;
String out = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:...
Makeshift asked 10/8, 2014 at 13:36
1
Solved
The following code snippet runs without error in Java 8. However, when I run the same code in Java 17 it fails.
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
public c...
6
Solved
Using Spring RestControllers with Jackson JSON parsing backend, with AngularJS on front end. I'm looking for an efficient way to have Jackson serialize an Instant as the epoch milliseconds for subs...
3
Solved
Java 8 introduced ChronoUnit which is largely equivalent to TimeUnit introduced in Java 5.
Is there an existing function for converting a TimeUnit to ChronoUnit? (Yes, I know how to write my own)
...
3
Solved
Basically, I am using the following code to parse string as LocalDateTime, which works fine most of the time.
DateTimeFormatter dtformatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
H...
8
Solved
Java 8 introduced java.time.Clock which can be used as an argument to many other java.time objects, allowing you to inject a real or fake clock into them. For example, I know you can create a Clock...
Elevenses asked 21/11, 2014 at 17:30
12
Solved
Java 8 added a new java.time API for working with dates and times (JSR 310).
I have date and time as string (e.g., "2014-04-08 12:30"). How can I obtain a LocalDateTime instance from the ...
3
Solved
My MCVE (as a TestNG unit test):
public class MyDateTimeFormatterTest {
private static final String BASE_PATTERN = "yyyy/MM/dd HH:mm:ss";
private static final DateTimeFormatter FORMATTER =
Dat...
Notochord asked 7/5, 2015 at 2:3
3
Solved
I am trying to format LocalDate variables to dd.MMM.YYYY with:
DateTimeFormatter.ofPattern("dd.MMM.yyyy")
The problem is that more half the time I get two dots. For example 01-01-2000 go...
Hellenize asked 6/11, 2021 at 2:22
17
Solved
I'm having a small problem with formatting a Java 8 LocalDateTime in my Spring Boot Application. With 'normal' dates I have no problem, but the LocalDateTime fields are converted to the following:
...
Erastianism asked 29/4, 2015 at 23:8
26
Solved
How do I use Jackson JSON mapper with Java 8 LocalDateTime?
org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple type, class java.time.LocalDateTime] from JSO...
17
Solved
I use Spring Boot and included jackson-datatype-jsr310 with Maven:
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</...
Perutz asked 27/10, 2016 at 0:46
3
Solved
I have an instance of Instant (org.joda.time.Instant) which I get in some api response. I have another instance from (java.time.Instant) which I get from some other call. Now, I want to compare the...
Gumption asked 22/7, 2016 at 17:36
11
Solved
In my test case, I need test time sensitive method, in that method we're using java 8 class LocalDate, it is not Joda.
What can I do to change time, when I'm running test
Adrianople asked 25/9, 2015 at 23:26
1 Next >
© 2022 - 2024 — McMap. All rights reserved.