Questions tagged [zoneddatetime]

`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.”

339 questions
3
votes
2 answers

Determine TimeZone from a JSON String?

I'm querying a JSON API that returns something like this: { "created_time": "2017-01-05T16:32:29+0100", "updated_time": "2017-01-11T09:38:41+0100", "id": "23842536731240607" } I need to store the times in UTC format, but in order to change…
gtludwig
  • 5,411
  • 10
  • 64
  • 90
3
votes
1 answer

ZonedDateTime with Oracle

I'm trying to persist ZonedDateTime to Oracle. Following is my domain entity class: @Entity @Table(name = "TESTTABLE") public class Order { private static final long serialVersionUID = 1L; @Type(type = "uuid-binary") @Column(name =…
Gurkha
  • 1,104
  • 4
  • 20
  • 37
3
votes
1 answer

Interrogate a ZonedDateTime asking if in standard time or in Daylight Saving Time (DST)

How to ask a java.time.ZonedDateTime object if Daylight Saving Time (DST) applies to its moment or if standard time applies?
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
3
votes
2 answers

ZonedDateTime parses successfully but output string is different

I am using the ZonedDateTime to parse and get current time according to the time zone. When I parse the following String, the parse succeeds but the output String is different. Why is that? String dateTimeString =…
Olayinka
  • 2,813
  • 2
  • 25
  • 43
2
votes
1 answer

convert string ("2022-12-23T07:20:00" ) time into ZonedDateTime

i was trying to convet string time into ZonedDateTime but not comes up with solution . This is the string format of time "2022-12-23T07:20:00" i have tried this approach String stringDate = "2022-12-23T07:20:00"; DateTimeFormatter dateTimeFormatter…
2
votes
1 answer

comparison operators vs comparison methods for ZonedDateTime

using <, >, and == is not always the same as using .isBefore, .isAfter and isEqual when comparing ZonedDateTimes as shown by the following example in Kotlin: import java.time.ZonedDateTime import java.time.ZoneId import java.time.ZoneOffset fun…
2
votes
3 answers

Compare ZoneDateTime with different time zones

Hi I've already search for similar questions but without luck. I'm calling a ws that sends me back a token and when it's valid example: { "token": ..., "notBefore":"Thu 21 Jul 2022 at 10:50:43", "notOnOrAfter":"Thu 21 Jul 2022 at…
Pp88
  • 830
  • 6
  • 19
2
votes
1 answer

how to manage the timezone which are not directly supported in java

we are getting the ZoneId object by passing the id string -> ZoneId.of("US/Alaska") While getting the timezone ids from java after passing the location name, we get error that "Exception in thread "main" java.time.zone.ZoneRulesException: Unknown…
Onki
  • 1,879
  • 6
  • 38
  • 58
2
votes
1 answer

DateTimeFormatter - java.lang.IllegalArgumentException: Too many pattern letters: a

I have the following line in my java code where I am trying to format a date string ZonedDateTime zonedDateTime= ZonedDateTime.ofInstant(instant, tz); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm aa"); return…
java12399900
  • 1,485
  • 7
  • 26
  • 56
2
votes
2 answers

DateTimeParseException while parsing date using ZonedDateTime

I have the below program and looks like ZonedDateTime is not able to parse the date string. Should I use a different date format or different library to parse? import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; class Scratch…
Zack
  • 2,078
  • 10
  • 33
  • 58
2
votes
2 answers

Converting Date String to ZonedDateTime

I'm receiving a query parameter date, as yyyy-MM-DD (2022-03-08). I want to conver this to java.util.Calendar / java.util.GregorianCalendar formmat. So my idea is converto: String -> ZonedDateTime -> Calendar. What I did: ZonedDateTime parsedDate =…
PlayHardGoPro
  • 2,791
  • 10
  • 51
  • 90
2
votes
1 answer

How to search by date Room Database?

I have a database in room database Android Studio in which I need to find the records that match a date that comes to me through an http query The problem I see is that since I am using a data converter (ZoneDateTimeConverter) when trying to make…
2
votes
2 answers

Duration.toHours returns zero

In the output section below, the "Hours in-between" displayed is zero. The result expected is a non-zero value. The Java code: ZonedDateTime zdt1 = ZonedDateTime.now(ZoneId.of("Asia/Calcutta")); ZonedDateTime zdt2 =…
2
votes
2 answers

DateTimeFormatter to parse string with both Zone offset and timezone

This question might sound similar to most of the other questions asked here on Stackoverflow but I could not figure out my problem. I want to parse the string value into a date. String dateTime = "23 Oct 2020 02:44:58 +1000" The solution to this…
2
votes
1 answer

Incorrect serialization of ZonedDateTime in JUnit tests. Date returns as Double

I have controller that returns the next DTO as JSON response public class CustomerInfo { private String name; private Integer customerId; private ZonedDateTime startDate; private ZonedDateTime paymentDueDate; private String…