Top "Java-time" questions

The java.

Why is ZoneOffset.UTC != ZoneId.of("UTC")?

Why does ZonedDateTime now = ZonedDateTime.now(); System.out.println(now.withZoneSameInstant(ZoneOffset.UTC) .equals(now.withZoneSameInstant(ZoneId.of("UTC")))); print …

java datetime java-8 java-time
Get first and last day of month using threeten, LocalDate

I have a LocalDate which needs to get the first and last day of the month. How do I do …

java date java-time
java.time.format.DateTimeParseException: Text could not be parsed at index 3

I am using Java 8 to parse the the date and find difference between two dates. Here is my snippet: String …

java-8 java-time date-parsing
How to create Java time instant from pattern?

Consider a code: TemporalAccessor date = DateTimeFormatter.ofPattern("yyyy-MM-dd").parse("9999-12-31"); Instant.from(date); The last line throws an exception: …

java java-time
How to reduce one month from current date and stored in date variable using java?

How to reduce one month from current date and want to sore in java.util.Date variable im using this …

java date datetime java-time
How to convert a LocalDate to an Instant?

I work with the new DateTime API of Java 8. How to convert a LocalDate to an Instant? I get an …

java datetime java-8 java-time
How to convert LocalDate to SQL Date Java?

How do I convert a LocalDate to a java.sql.Date? Attempt: Record r = new Record(); LocalDate date = new Date(1967, 06, 22); …

java java-8 converter java-time sqldatetime
How to use LocalDateTime RequestParam in Spring? I get "Failed to convert String to LocalDateTime"

I use Spring Boot and included jackson-datatype-jsr310 with Maven: <dependency> <groupId>com.fasterxml.jackson.datatype</…

spring spring-boot spring-mvc java-time jsr310
Java 8 Convert given time and time zone to UTC time

I have a time with string type like: "2015-01-05 17:00" and ZoneId is "Australia/Sydney". How can I convert this …

java java-8 utc java-time
long timestamp to LocalDateTime

I have a long timestamp 1499070300 (equivalent to Mon, 03 Jul 2017 16:25:00 +0800) but when I convert it to LocalDateTime I get 1970-01-18…

java java-8 timestamp java-time