`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
3
votes
2 answers
Serialisation format of ZoneDateTime stored as JSONB in PostgreSQL
trying to store complex data in PostgreSQL as JSONB.
Storage works fine except the format of attributes of type java.time.ZonedDateTime.
1 - Given is the entity Route:
@TypeDef(name = "jsonb", typeClass =…

lxndr
- 53
- 4
3
votes
2 answers
Do we have setCurrentMillisFixed in Java 8?
In Joda we have setCurrentMillisFixed method which can be used to set current system time:
DateTimeUtils.setCurrentMillisSystem();
In Java 8 i am trying :
ZonedDateTime.now(Clock.systemDefaultZone());
But lot of test cases are failing, i am…

Parameswar
- 1,951
- 9
- 34
- 57
3
votes
1 answer
Java.time from offset to timezone name
Trying to convert a various of time formats to a unified format.
One format is
"uuuu-MM-dd'T'HH:mm:ss-5000"
need to convert to the timezone format:
"uuuu-MM-dd'T'HH:mm:ss EST"
Using the following code, but it only gives the timezone as "-05:00",…

user2777473
- 3,736
- 5
- 26
- 39
3
votes
2 answers
How to normalise ZonedDateTime so that .equals() works?
I have code, similar to this:
import java.time._
object app {
def main (args :Array[String]) = {
println("app started")
// create two ZonedDateTime objects for 1st Jan 2018, 10am UTC
// using separate methods
val zdt1 =…

Philluminati
- 2,649
- 2
- 25
- 32
3
votes
3 answers
converting epoch to ZonedDateTime in Java
How to convert epoch like 1413225446.92000 to ZonedDateTime in java?
The code given expects long value hence this will throw NumberFormatException for the value given above.
ZonedDateTime.ofInstant(Instant.ofEpochMilli(Long.parseLong(dateInMillis)),…

Sajin Surendran
- 248
- 6
- 17
3
votes
1 answer
How to add server timezone to localdatetime during JSON serialization?
I use LocalDateTime for all timestamps in the RESTful web service and all timestamps initialization and changes are made on the server.
When the client of the service creates some resource then the server internally assigns creation timestamp to…

Ilya Zinkovich
- 4,082
- 4
- 25
- 43
3
votes
2 answers
Getting time range between the first day of current week and current time JDK 8
I can easilly calculate time period between the first day of month and current time:
/**
* Returns the time range between the first day of month and current time in milliseconds.
*
* @param zoneId time zone ID.
* @return a {@code long} array,…

Ernestas Gruodis
- 8,567
- 14
- 55
- 117
3
votes
2 answers
Parsing a string into a ZonedDateTime with a DateTimeFormatter
I'm trying to parse this String into a ZonedDateTime:
"Mon 14 Aug 2017 02:00 AM CEST"
Here my last try:
System.out.println("Test ZonedDateTime: " + ZonedDateTime.parse(
"Mon 14 Aug 2017 02:00 AM CEST",
…

Anonymuf
- 59
- 1
- 6
3
votes
1 answer
Java SimpleDateFormat.getTimeZone().getID() returns Asia/Jerusalem instead of Asia/Kolkata
SimpleDateFormat's getTimeZone().getID() method returns Asia/Jerusalem instead of Asia/Kolkata for the date with format EEE MMM dd HH:mm:ss z yyyy. Actually in my development machine it returns Asia/Kolkata as expected. But in some other…

saikamesh
- 4,569
- 11
- 53
- 93
3
votes
3 answers
Trying to parse a datetime in PDT to a ZonedDateTime representation
How should I parse this datetime value that is in the PDT timezone?
06/24/2017 07:00 AM (PDT)
I want to maintain the timezone so that I can then represent the time in other timezones depending on the website visitors preferences.
I tried using…

Blankman
- 259,732
- 324
- 769
- 1,199
3
votes
2 answers
How to compare LocalDate with ZonedDateTime in js-joda?
I'm looking for a way to compare instances of LocalDate and ZonedDateTime in js-joda, but those classes are not compatible. I'm willing to accept, that LocalDate is a ZonedDateTime with time and timezone set to zero.
What would be the easiest way to…

Slava Fomin II
- 26,865
- 29
- 124
- 202
3
votes
2 answers
How to handle all Zone Offset in one DateTimeFormater Java 8
I need to create a DateTimeFormatter for the following valid dates.
String date1 = "2017-06-20T17:25:28";
String date2 = "2017-06-20T17:25:28.477777";
String date3 = "2017-06-20T17:25:28.477777Z";
String date4 =…

Amit Garg
- 838
- 1
- 10
- 21
3
votes
1 answer
ZonedDateTime round trip via Jackson produces unequal ZonedDateTime
Given the following Unit tests:
@Test
public void zonedDateTimeCorrectlyRestoresItself() {
// construct a new instance of ZonedDateTime
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Z"));
// offset = {ZoneOffset@3820} "Z"
// zone…

fIwJlxSzApHEZIl
- 11,861
- 6
- 62
- 71
3
votes
1 answer
Does Java 8's ZonedDateTime take into account daylight savings when converting?
I have the following code below:
ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(
this.start.toLocalDateTime(), ZoneOffset.UTC,
ZoneOffset.systemDefault());
The this.start is from a java.sql.Timestamp. I am explicitly…

Darren
- 10,631
- 8
- 42
- 64
3
votes
2 answers
Compute Week of Year issues with ZonedDateTime and Calendar API
I was trying to compute week of year from a ISO-8601 Date format String input. Initially I tried this with java.time.ZonedDateTime but it gives incorrect result for Input Date - 2-Jan-2049. Then I tried with Calendar API it also gives incorrect…

kanchan
- 167
- 2
- 13