java-time Questions

3

Solved

I am using DateTimeFormatter to format date: ZonedDateTime date = ZonedDateTime.parse("2015-12-03T18:15:30+01:00[America/New_York]"); DateTimeFormatter formatter = DateTimeFormatter.ofLocalized...
Halsy asked 3/1, 2019 at 3:28

1

Solved

Given this date I want to parse: 15th Dec 16:00 +01:00 with this code Map<Long, String> ordinalNumbers = new HashMap<>(42); ordinalNumbers.put(1L, "1st"); ordinalNumbers.put(...
Woolpack asked 16/12, 2018 at 3:23

0

Backstory I recently came across a problem with saving a LocalTime to a TIME column in a MySQL database. Saving a value of 9:00 was causing 8:00 to be saved in the database. This problem did not ...
Subteen asked 11/12, 2018 at 14:4

2

Solved

Why does java.time.Clock has zone information? From the Clock you only can get an Instant when calling the instant() method - which is a time without zone info. Is the only purpose to have the zon...
Belding asked 28/11, 2018 at 10:59

0

Running: Locale locale = Locale.US; String pattern = DateTimeFormatterBuilder.getLocalizedDateTimePattern( FormatStyle.LONG, FormatStyle.LONG, Chronology.ofLocale(locale), locale); Sys...
Hedgehop asked 15/11, 2018 at 10:29

0

I'm trying to migrate an old library to use the "new" Java time API and struggle on one point. Context I developed quite some time now an application to handle charts in the banking industry. So ...
Consuelaconsuelo asked 9/11, 2018 at 11:2

4

Solved

What's the best way to convert between LocalDate from Java 8 and XMLGregorianCalendar?
Armbruster asked 21/4, 2015 at 8:42

1

Solved

I was able to reproduce my problem with a minimal modification of the official Spring Boot guide for Accessing Data with MongoDB, see https://github.com/thokrae/spring-data-mongo-zoneddatetime. Aft...
Dissonancy asked 6/10, 2018 at 8:41

1

Solved

I have some old convenience methods, written using Calendars, that I want to update to use the Java.time.* classes introduced in Java 8. Some of the methods in my class get quantities like the curr...
Remediable asked 23/10, 2018 at 19:16

2

Solved

I am using the ZonedDateTime with DateTimeFormatter of Java 8. When I try to parse my own pattern it doesn't recognizes and throws an exception. String oraceDt = "1970-01-01 00:00:00.0"; DateTim...
Cheroot asked 25/1, 2016 at 23:1

2

Solved

I need to convert a LocalDateTime object to a new Instant object. I've realized LocalDateTime has an toInstant method, but it's requesting me an ZoneOffset. I don't quite figure out how to use it...
Greatniece asked 23/10, 2018 at 8:25

2

Solved

I know JAXB (Java Architecture for XML Binding) can marshal/unmarshal java.util.Date objects as seen in this answer by Blaise Doughan. But what about the new java.time package objects in Java 8, s...
Amnesty asked 16/6, 2014 at 19:54

5

Solved

I need to convert java.util.Date to String in yyyy-MM-dd format in a big amounts. I have just moved to java 8 and want to know how to do it properly. My solution with Java 7 was like: DateTimeFor...
Crackpot asked 18/10, 2018 at 9:16

3

There's hibernate-java8 JAR providing adapters for a couple of classes like Instant, LocalDate, etc., but some classes from java.time, e.g., Year, Month, YearMonth are missing. These classes get st...
Picador asked 28/3, 2017 at 1:31

1

Solved

I have an eta value that is an OffsetDateTime and I have a scheduledDate that is a Date type. If the eta isn't set I want to fall back to the Date. An example of the date is Tue Jul 21 10:32:28 PD...
Morrell asked 3/10, 2018 at 17:56

2

Solved

Do we know if there is an equivalent format string that outputs the same result as DateTimeFormatter.ISO_OFFSET_DATE_TIME? i.e. ZonedDateTime dateTime = ZonedDateTime.now(); System.out.println(da...
Planck asked 3/10, 2018 at 3:39

4

Solved

I'd like to parse '2015-10-01' with LocalDateTime. What I have to do is LocalDate localDate = LocalDate.parse('2015-10-01'); LocalDateTime localDateTime = localDateTime.of(localDate, LocalTime.MIN...
Hibbard asked 6/10, 2015 at 5:35

8

Solved

Is there a usablility to get all dates between two dates in the new java.time API? Let's say I have this part of code: @Test public void testGenerateChartCalendarData() { LocalDate startDate = L...
Hobie asked 6/7, 2016 at 9:25

3

Solved

I'm working on converting some models in a spring-boot REST API app to use java 8's java.time.LocalDateTime instead of joda's DateTime. I want the timestamps returned from API call to adhere to the...
Fishing asked 28/7, 2016 at 6:32

2

I have GMT0 as the default timezone in a system and it causes problem when I'm serializing it and deserializing it just after that. System.setProperty("user.timezone","GMT0"); DateTimeFormatter zo...
Gentianaceous asked 23/8, 2018 at 8:34

4

Solved

I have the time in milliseconds and I need to convert it to a ZonedDateTime object. I have the following code long m = System.currentTimeMillis(); LocalDateTime d = LocalDateTime.millsToLocalDat...
Kirwan asked 21/8, 2018 at 16:24

1

Solved

I run a simple query to retrieve a row from a MySQL database. I get ResultSet and I need to retrieve a LocalDateTime object from it. My DB table. CREATE TABLE `some_entity` ( `id` bigint(20...
Steelworks asked 1/8, 2018 at 11:59

2

Solved

I am trying to figure out why Jackson (2.9.5) formats dates from Java 8 incorrectly. data class Test( val zonedDateTim: ZonedDateTime = ZonedDateTime.now(), val offsetDateTim: OffsetDateTime = Of...
Unfasten asked 27/7, 2018 at 11:27

3

Solved

Migrating Joda time to Java 8 Joda: UserObject user = new UserObject() user.setCreatedAt(new DateTime(rs.getTimestamp("columnName")));` Migrating to Java 8 This is my code; it does compile; I ...
Exclude asked 16/7, 2018 at 18:52

4

Solved

I need to parse date-times as strings coming as two different formats: 19861221235959Z 1986-12-21T23:59:59Z The following dateTimeFormatter pattern properly parses the first kind of date string...
Penology asked 4/7, 2018 at 15:24

© 2022 - 2024 — McMap. All rights reserved.