Skip to content
Advertisement

Tag: zoneddatetime

ZonedDateTime to Date before Java 8 in early Android

I am trying to replace the ZonedDateTime.toInstant method because it is only available since API 26 for Android. But my app is supposed to support API 19. I want to convert the ZonedDateTime to a Date so i can do something like this: What i want to achieve is the following: I want to calculate the difference between the current

LocalTime() difference between two times

I have a flight itinerary program where I need to get difference between departure and arrival time. I get these specified times as String from the data. Here is my problem: Output: The first time returns the difference between 11:39 and 14:35 just fine. But the second difference is only 5 hours while it should be 19 hours. How can

Converting string to ‘Instant’

I am trying to convert datetime in a string to an Instant instance using Java 8 or a utilities package. For example, to reqString is in the America/Toronto time zone. This is what I tried The above code results in “2018-05-12T23:30:00Z”. How can I do it? Answer tl;dr Fix your formatting pattern for unpadded month and day. Use only java.time

Advertisement