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, ...

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...
Memling asked 13/8, 2019 at 13:42

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...
Doubleripper asked 17/2, 2021 at 18:31

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...
Stillhunt asked 19/12, 2021 at 15:31

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);
Persia asked 29/5, 2019 at 13:3

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...

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...
Unbowed asked 18/6, 2015 at 12:5

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 ...
Crossruff asked 1/4, 2014 at 17:56

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...
Quinn asked 14/5, 2015 at 10:8

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...
Financier asked 30/1 at 18:5

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...
Protect asked 23/6, 2016 at 19:1

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) ...
Siva asked 27/10, 2014 at 5:37

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...
Jumpoff asked 22/4, 2018 at 14:40

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 ...
Excide asked 17/3, 2014 at 19:0

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...
Frambesia asked 14/1, 2015 at 21:8

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

© 2022 - 2024 — McMap. All rights reserved.