java-time Questions

3

Solved

I get this error with this code: SimpleDateFormat sdf = new SimpleDateFormat("EEEE dd MMMM HH:mm yyyy",myDateFormatSymbols); sdf.parse("понеділок 12 квітень 07:00 2021"); Whis ...
Tragopan asked 9/4, 2021 at 22:14

2

Solved

I have tried using - int startSeconds = restaurant.openingTime.toSecondOfDay(); int endSeconds = restaurant.closingTime.toSecondOfDay(); LocalTime timeBetweenOpenClose = LocalTime.ofSecondOfDay(Thr...
Burmeister asked 3/4, 2021 at 10:43

1

Solved

I'm parsing logs from different sources, I'm extracting datetime string from log. Now I want to convert it into java ZonedDateTime. Problem here is, I don't know exact datetime format, I just know ...
Vigesimal asked 31/3, 2021 at 12:6

4

Solved

When creating a new LocalDateTime using LocalDateTime.now() on my Mac and Windows machine i get a nano precision of 6 on my Mac and a nano precision of 3 on my Windows machine. Both are running jdk...
Threefold asked 26/8, 2018 at 20:15

4

I am trying to use java.time.LocalDate in my android app, however if I try to import it, then any class from java.time gives a cannot resolve symbol error in Android studio 1.1 The only reason I c...
Mencius asked 26/2, 2015 at 14:37

4

Solved

I created two ZonedDateTime objects and I think they are should be equal: public static void main(String[] args) { ZoneId zid = ZoneId.of("America/New_York"); ZoneOffset offset = ZoneOffset.from...
Formate asked 11/9, 2014 at 17:28

3

Solved

I have the following joda date parser: ISODateTimeFormat.dateTimeParser().withOffsetParsed(). I'd like to refactor this to java.time api. But what is the exact equivalent to the parser above, esp...
Urano asked 13/7, 2016 at 10:21

3

Solved

I am trying to parse: 2014-05-02-10.45.05.993280-5:00 where the -5:00 is the offset from UTC. Using a java.time DateTimeFormatter in Java 8. For the first bit I have the following: yyyy-MM-dd-HH.m...
Lucic asked 8/6, 2015 at 13:45

5

Solved

I am trying to learn the new Date & Time API. My code is working except for the last line: LocalDate current=LocalDate.now(); System.out.println(current); LocalDate personaldate=LocalDate.of(...
Ramiah asked 23/12, 2015 at 17:31

2

Solved

Getting date from https://api.spacexdata.com/v3/launches This date have format: 2006-03-25T10:30:00+12:00. I want convert it to "dd, mm, yyyy", but always getting error: "java.time.f...

3

Solved

I am trying to parse some dates, but the DateTimeParser seems to disagree with me on what is valid import java.time.ZonedDateTime import java.time.format.DateTimeFormatter import java.util.Locale ...
Scarberry asked 7/7, 2016 at 16:9

0

I have a best practices question with regards to mapping Instant to PostgreSQL TIMESTAMP. We've updated our app to Java 15 and the new enhancement of the system clock to nanosecond precision ...
Odawa asked 6/1, 2021 at 11:23

1

Solved

I want to parse custom multiple Date formats in Java. Here is my code Scenario 1: Order of patterns: yyMMdd'h'HH yyMMdd DateTimeFormatter formatter = new DateTimeFormatterBuilder() .appendOption...
Kenya asked 30/12, 2020 at 8:6

3

Solved

In the java.time framework of Java 8 and later, the Duration class says: This class models a quantity or amount of time in terms of seconds and nanoseconds. It can be accessed using other durati...
Seminar asked 2/2, 2016 at 23:7

3

Solved

How to sort LocalDateTime objects? I tried the following: Comparator<Data> comparator = new Comparator<Data>() { @Override public int compare(final data o1, final data o2) { if (o1...
Ecstasy asked 17/9, 2015 at 8:8

10

Convert LocalDateTime to LocalDateTime in UTC. LocalDateTime convertToUtc(LocalDateTime date) { //do conversion } I searched over net. But did not get a solution
Undersexed asked 6/1, 2016 at 5:42

7

Solved

I have an entity with java.time.Instant for created data field: @Getter @Setter @AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode public class Item { private String id; private String ur...
Bolitho asked 13/8, 2017 at 17:4

5

Solved

I have problems with Date class in Java. Date class returns local machine date but i need UTC-0. I have googled and found great solution for JavaScript but for Java nothing useful. How to get UTC...
Belk asked 1/10, 2014 at 13:44

2

Solved

Let's say that we have an appointment in Milan Italy happening on 01/23/2021 21:00 "Europe/Rome". This appointment is saved to the database in UTC in a column of a type akin to the SQL-st...
Mixtec asked 26/10, 2020 at 21:57

9

Solved

Java 8 has a completely new API for date and time. One of the most useful classes in this API is LocalDateTime, for holding a timezone-independent date-with-time value. There are probably million...
Honeyman asked 17/10, 2013 at 15:40

2

Solved

Time zone ids of Joda Time can simply be displayed with the following segment of code. Set<String> zoneIds = DateTimeZone.getAvailableIDs(); for(String zoneId:zoneIds) { System.out.println...
Inkerman asked 12/4, 2013 at 9:26

2

I am trying to get the local time in spark-scala but it is returning UTC. I am using java.time.LocalDateTime to get the current timestamp. But its returning the UTC standard. java.sql.Timestamp.v...

3

Solved

I want to get the difference in seconds to find whether the system timezone is ahead or behind the remote timezone. Here the remote timezone value is "GMT" which i fetch from Database. It...
Module asked 16/9, 2020 at 7:59

2

Solved

I am trying to parse a date string using the following pattern: yyMMdd and the STRICT resolver as follows: DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat).withResolverStyle(R...
Pergola asked 12/12, 2016 at 14:56

3

Solved

I want to parse a date string like 2011-11-30 like this: LocalDateTime.parse("2011-11-30", DateTimeFormatter.ISO_LOCAL_DATE) But I get the following exception: java.time.format.DateTimeParseExc...
Derwin asked 9/1, 2016 at 23:2

© 2022 - 2024 — McMap. All rights reserved.