java-time Questions

5

Solved

I want to format my Java 8 LocalDateTime object in "dd.MM.yyyy" pattern. Is there any library to format? I tried code below but got conversion exception. <fmt:parseDate value="${date}" pattern=...
Robbynrobe asked 24/2, 2016 at 15:44

1

Solved

I have following code to convert an Instant to String then convert it back to I String timestampString = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss")); LOGGER.info...
Analyse asked 7/6, 2019 at 19:49

6

Solved

I'm looking for a module for the new JDK8 java.time classes. I have looked through the FasterXML GitHub Project Listing and presently found none. As I understand Jackson is still being compiled ag...
Leviticus asked 27/1, 2014 at 15:30

3

Solved

I noticed that java.time.format.DateTimeFormatter is not able to parse out as expected. See below: import java.time.LocalDate; import java.time.format.DateTimeFormatter; public class Play { publi...
Folse asked 28/5, 2015 at 23:54

3

Solved

Assuming the following code... Instant x = Instant.now(); How do I get day of week from x?
Waterline asked 29/5, 2019 at 15:47

3

Solved

With the first release of Java 8 (b132) on Mac OS X (Mavericks), this code using the new java.time package works: String input = "20111203123456"; DateTimeFormatter formatter = DateTimeFormatter....
Sarina asked 23/3, 2014 at 7:8

1

This is not a duplicate as some people think. It is about two standard Java classes for formatting dates that produce different strings for the same value of milliseconds since the epoch. Fo...
Dunigan asked 13/5, 2019 at 23:26

2

Solved

On Wikipedia time zone offsets are explained as the difference in hours and minutes from standard UTC time. However, DateTimeFormatter supports zone-offset pattern XXXXX, which "outputs the hour an...
Hanus asked 23/4, 2019 at 12:5

4

Solved

I'm Using Java 8, Earlier in our code, We were using sdf.setTimeZone(TimeZone.getTimeZone("PDT")); to convert to US Pacific which was failed(not throwing any errors but converted to default timez...
Eterne asked 11/4, 2019 at 8:6

1

I am getting the LocalDateTime two hours lesser than the real time. How can I get the offset time for Berlin, Germany for the code below? LocalDateTime dateTime = LocalDateTime.ofEpochSecond(second...
Strychnine asked 3/4, 2019 at 11:26

4

Solved

The documentation for java.time.temporal.Temporal contains the following note: Implementation Requirements: [...] All implementations must be Comparable. Why does Temporal not just extend Comp...
Encyclopedic asked 26/5, 2014 at 13:10

2

I have a simple jUnit test for DateTimeFormatterBuilder. At runtime it works, when some String comes on Spring-MVC hanlder (@RequestParam) At testtime it fails with the same String value. T...
Tribal asked 25/5, 2018 at 9:46

2

Solved

I have some legacy KML documents which includes a time stamp entry. Why is the below date not valid when using Instant to parse? Both methods are suppose to parse ISO 8601 formatted dates. String ...
Umbrage asked 22/3, 2019 at 16:41

1

Solved

Let's say I have a ZonedDateTime: ZonedDateTime zonedDateTime = ZonedDateTime.of(LocalDateTime.now(), ZoneId.of("US/Pacific")); I would like to know which date/time it is let's say in Berlin. ...
Vientiane asked 6/3, 2019 at 21:50

5

Solved

Is there a nicer/easier way of constructing LocalDateTime object representing today at 6 AM than this? LocalDateTime todayAt6 = LocalDateTime.now().withHour(6).withMinute(0).withSecond(0).withNano...
Swabber asked 28/4, 2016 at 12:23

3

Solved

Is there anyway to get a java.time (new in Java 8) compatible time class out of a ResultSet? I am aware you can use ResultSet's getDate or getTimestamp but these method return java.sql.Date / jav...
Karlee asked 21/4, 2015 at 13:19

5

Solved

The following piece of code: Instant inFourWeeks = Instant.now().plus(4L, ChronoUnit.WEEKS); Throws an exception: java.time.temporal.UnsupportedTemporalTypeException: Unsupported unit: Weeks ...
Shopwindow asked 24/2, 2019 at 11:11

4

Solved

I am getting the following exception while trying to convert java.util.Date to java.time.LocalDate. java.time.DateTimeException: Unable to obtain ZonedDateTime from TemporalAccessor: 2014-08-19T0...
Recurve asked 19/8, 2014 at 5:31

4

Solved

I only found a solution for Joda Time. My solution works only if the last day is not in the first week: LocalDate.now() // or any other LocalDate .withDayOfMonth(31) .withMonth(12) .get(weekFi...
Anurag asked 26/5, 2017 at 9:15

6

Solved

Of the Duration class in the new JSR 310 date API (java.time package) available in Java 8 and later, the javadoc says : This class models a quantity or amount of time in terms of seconds and na...
Dianoia asked 30/6, 2014 at 13:28

5

Solved

I need to check if a given date falls in the current month, and I wrote the following code, but the IDE reminded me that the getMonth() and getYear() methods are obsolete. I was wondering how to do...
Inconsistency asked 9/11, 2014 at 1:34

4

Solved

We're migrating from Joda to Java Time. Currently we use DateTime of Joda in our entity. AFAIK DateTime is equivalent to two types in Java: OffsetDateTime and ZonedDateTime. Since we're going to pe...

2

Solved

We have a library used for generating reports. It reads from a data file (SQL, XML, JSON, etc.), the datetime may then be modified in a user written equation, and then it is formatted as specified ...
Judgeship asked 25/1, 2019 at 14:45

5

Solved

I currently have a Joda date parser that uses the DateTimeFormatterBuilder with half a dozen different date formats that I may receive. I'm migrating to Java 8's Date routines and don't see an equ...
Belford asked 23/3, 2016 at 20:49

2

I am trying to store OffsetDateTime("2019-01-14 21:10:00.02+03") with timezone(+03) using JDBC to PostgreSQL. But when retrieve data using sql query I always get the +00 result. Is there any way to...

© 2022 - 2024 — McMap. All rights reserved.