`ZonedDateTime` is a standard Java class representing a “date-time with a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30+01:00 Europe/Paris.”
Questions tagged [zoneddatetime]
339 questions
4
votes
2 answers
Convert String into java.time.ZonedDateTime
I want to convert elements of an array list into ZonedDateTime object after parsing them. A string is shown below.
"2017-02-12 06:59:00 +1300"
At the moment I use the DateTimeFormatter:
DateTimeFormatter dateTimeFormatter =
…

SSF
- 915
- 5
- 23
- 47
4
votes
2 answers
java 8 getting timeZone from zonedLocalTime
I am writing a helper method that takes String representation of date and returns TimeZone
for example:
input: 2017-11-02T09:30:00-07:00
output : "America/Los_Angeles"
(Here the input is PST. I am using UTC offset of -7:00)
Here is my method
…

brain storm
- 30,124
- 69
- 225
- 393
4
votes
2 answers
Getting time range between midnight and current time JDK 8
I have this method to calculate midnigt and current time as long values:
/**
* Returns the time range between the midnight and current time in milliseconds.
*
* @param zoneId time zone ID.
* @return a {@code long} array, where at index: 0 -…

Ernestas Gruodis
- 8,567
- 14
- 55
- 117
4
votes
2 answers
How to use some Jackson Deserializer in own custom Deserializer?
I am struggling with mentioned in the question issue.
I need to create some custom deserializer which is more or less type conversion from the standard deserializer (reason is that ZonedDateTime is working for my input, but I don't want to change…

Marek Urbanowicz
- 12,659
- 16
- 62
- 87
4
votes
3 answers
Deserialize "Zulu" time in ISO8601 format in jackson
I have a need to de-serialize time of format 2016-11-28T10:34:25.097Z using Jackson into ZonedDateTime of Java8.
I believe I correctly configured ObjectMapper (a factory method):
@Bean
ObjectMapper getObjectMapper() {
ObjectMapper objectMapper…

onkami
- 8,791
- 17
- 90
- 176
4
votes
1 answer
behavior of ZonedDateTime when parsing string with conflicting zone id and offset
I could not find what the expected behavior is when parsing a string with a conflicting zone id and offset.
For example:
ZonedDateTime d = ZonedDateTime.parse("2015-06-17T12:55:33+05:00[Europe/Amsterdam]");
println(d.toString()); // prints…

rve
- 5,897
- 3
- 40
- 64
3
votes
1 answer
Timezone BST has wrong offset
Cannot understand why BST (UTC Offset: UTC +1) got offset +11 in following code. I would expect +1.
final String lastUpdated = "Mon Sep 27 18:29:00 BST 2021";
final DateTimeFormatter LAST_UPDATED_FORMATTER = DateTimeFormatter.ofPattern("EEE MMM dd…

alibaab
- 35
- 3
3
votes
2 answers
Java time parse "Jun 26th 2021, 04:30:15 pm NY"
I have a String that look like this:
String str = "Jun 26th 2021, 04:30:15 pm NY";
I want to convert it to ZonedDateTime, for this I use DateTimeFormatterBuilder:
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
…

Pekka
- 141
- 2
- 11
3
votes
2 answers
Spring rest controller removes plus sign from zonedatetime in query parameter
I have UT, that succesfully passed
@Test
public void test() {
String text1 = "2009-07-10T14:30:01.001Z";
String text2 = "2009-07-10T14:30:01.001+03:00";
DateTimeFormatter f =…

Roberto
- 1,288
- 5
- 23
- 47
3
votes
1 answer
ZonedDateTime in Brazil still getting -2 instead of -3 offset
I'm working in a application that uses Java 8, Maven and Spring. Since 2019, the DayLight Saving Time was abolished in Brazil.
Basically I am changing all dates in the system to save in utc and be shown in the time zone of whoever is using the…

Vinícius Britto
- 320
- 1
- 9
3
votes
3 answers
to display local date/time for different countries in java
I have to display local date time for different countries in java.Currently I am setting zoneId for "America/New_York" and so only getting EST time for all the places on the server.How to achieve local date/time dynamically.
DateTimeFormatter…

Anjali Singh
- 31
- 2
3
votes
3 answers
Local datetime parsing
I am trying to parse an input string to local date time.
Below is my piece of code
ZonedDateTime z = ZonedDateTime.parse("2019-11-26T19:30:00Z", MY_DATE_TIME_FORMATTER);
where
MY_DATE_TIME_FORMATTER= new DateTimeFormatterBuilder()
…

Ram Viswanathan
- 181
- 3
- 14
3
votes
1 answer
Local date time in certain format yyyy-MM-dd-HH.mm.ss.SSSSSS
I am trying to get LocalDateTime in certain format for my spring data jpa entity column.
I am not getting last 3 digits of millis/micros. I am not sure exactly what to call it.
I am always getting 000 for last 3 SSS portion even If I format
final…

Nagendra Busam
- 235
- 1
- 5
- 19
3
votes
3 answers
Java8 time library does not interpret BST timezone correctly
I am in the process of migrating my code to use the java.time package but I found that DateTimeFormatter does not interpret the time zone "BST" (British Summer Time) correctly.
Instead of making it UTC+0100, it converted it to Pacific/Bougainville…

Libby Shen
- 65
- 5
3
votes
4 answers
Java 8 Convert UTC time to EDT/EST so that date remains the same
I am using ZonedDateTime for a variable in java.
I want to convert the value of the variable (default UTC timezone) into the timezone of "America/New York" such that the date remains the same.
Example 4:00 am UTC = 12:00 am EST. Add or subtract…

harry1102
- 81
- 1
- 2
- 10