`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
0
votes
1 answer
Issue creating ZonedDateTime instance based on LocalDateTime
I'm seeing some behavior I can't explain, hoping somebody can point me in the right direction.
I'm first creating a LocalDateTime instance, then getting to ZonedDateTime by applying the "Europe/London" time zone to the LocalDateTime and then use a…

Simon Roggeman
- 3
- 1
0
votes
2 answers
java.time.format.DateTimeParseException using DateTimeFormatter
I have this code:
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.appendPattern(DateType.DATE_FORMAT)
.appendOffset("+HH:mm", "+00:00")
…

All_Safe
- 1,339
- 2
- 23
- 43
0
votes
4 answers
Parse ZonedDateTime.now() with DateTimeFormatter in Java
I am trying to parse the current timestamp with specific format but every try I keep getting a java.time.format.DateTimeParseException. My code:
ZonedDateTime.parse(
ZonedDateTime.now().toString(),
DateTimeFormatter.ofPattern("dd.MM.yyyy…

Arthur Eirich
- 3,368
- 9
- 31
- 63
0
votes
2 answers
Daylight saving time from ZonedDateTime not working as expected
I have the following function
public String getDateAndTimeInUserFormat(String value, DateTimeFormat inputFormat) {
return ZonedDateTime.parse(value, DateTimeFormatter.ofPattern(inputFormat.getFormat()))
…

tzortzik
- 4,993
- 9
- 57
- 88
0
votes
0 answers
Handling timezone depending upon the server timezone
I need to set the timezone in my application according to my server timezone. my server timezone in IST= Asia/Kolkatta. In java8, timezone can be set directly in @JsonFormat like this:
@JsonCreator
public SystemDateResponseDTO (@JsonFormat(shape =…
0
votes
1 answer
Writing xstream Converter for ZonedDateTime
In order to change from Calendar to ZonedDateTime (java.time) I have to write a converter for ZonedDateTime for xstream.
In this article https://github.com/x-stream/xstream/issues/24 is was suggested
What you can actually do is writing a custom…
user5354385
0
votes
2 answers
ZonedDateTime -> ChronoUnit.HOURS.between(zd1(Hour 2), zd2(Hour 1)) return -2
I am trying to understand why is it that the result of the code is -2, initially I thought it should be -1, but this one really puzzled me
LocalDateTime ld1 = LocalDateTime.of(2015, Month.NOVEMBER, 1, 2, 0);
ZonedDateTime zd1 = ZonedDateTime.of(ld1,…

mark ortiz
- 659
- 1
- 6
- 13
0
votes
1 answer
Get plural and single from Chrono Time unit
I need to display in Android "1 minute ago" and "2 minutes ago" by using plurals. The problem is that I am having a map of time units with a suffix.
val suffixes = mapOf(
ChronoUnit.WEEKS to context.getString(R.string.time_units_week),
…

Rene Gens
- 480
- 6
- 18
0
votes
1 answer
Parsing mysql date to ZonedDateTime
I'm trying to parse data coming from MySql in the following format:
DATE_FORMAT(datetime,'%m-%d-%Y %H:%i')
Java parser code looks like this:
ZonedDateTime datetime = ZonedDateTime
.parse(
…

AnKing
- 1,994
- 6
- 31
- 54
0
votes
1 answer
How do you save a UTC Timestamp?
How do you convert a ZonedDateTime to an SQL Timestamp and retain the Timezone info?
I am trying to take a UTC zoned time, convert it to a Timestamp, and then convert it back, but when I convert to Timestamp, it loses the time zone info and the…

Skywarp
- 989
- 3
- 15
- 32
0
votes
1 answer
creating date with different zones in java8
I am trying to create Date object with US timezone from system default timezone.
I am using java 8 new date time APIs. To create date object I am making use of
Calendar API. Is there any way I can create Date object with out Calendar?
The below code…

user3305063
- 461
- 1
- 5
- 15
0
votes
4 answers
How do I convert yyyy DDD HH:mm:ss into a ZonedDateTime>
I've been working on some code for a while and I can't seem to figure this bit out. I've got 5 spinners for each field of year, day of year, hour, minute, and second. My goal is to take those 5 parameters and use them to create a ZonedDateTime that…

mightynifty
- 149
- 1
- 13
0
votes
2 answers
ZonedDateTime gives incorrect UTC offset values
I m using ZonedDateTime library from Java to retrieve UTC offset of any timezone out of the standard timezone list (Olson timezone database).
Here is my simple code.
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class…

Kedar Prabhu
- 316
- 3
- 6
0
votes
1 answer
How to get time difference between two ZonedDateTimes and pretty print it like "4 hours, 1 minute, 40 seconds ago"?
This is how I call getTimeBetween function:
getTimeBetween(ZonedDateTime.now().minusHours(4).minusMinutes(1).minusSeconds(40), ZonedDateTime.now());
And I expect this output:
4 hours, 1 minute, 40 seconds ago
This is my getTimeBetween…

Defozo
- 2,946
- 6
- 32
- 51
0
votes
0 answers
Unable to obtain ZonedDateTime from TemporalAccessor when parsing a date string generated from a ZonedDateTime
I format a ZonedDateTime then attempt to parse it and get the following exception.
public static void main(String[] args){
String timeStr=ZonedDateTime.now().format(DateTimeFormatter.ISO_INSTANT);
System.out.println(timeStr);
…

Jeff Gaer
- 134
- 1
- 11