Sometimes you want to change the time of localDateTime, but Calendar can only change the information of date. You need to convert date to localDateTime or change localDateTime to date.
//date->localDateTime
Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime()
//localDateTime->date
Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
Read More:
- Local date time conversion in java8
- 1、 Java 8 date and local date
- ‘Conversion failed when converting date and/or time from character string.DB-Lib error message 241,
- How to receive localdatetime type in background
- [Solved] Flowable Start Error: ClassCastException: java.time.LocalDateTime cannot be cast to java.lang.String
- Dataframe and np.array The mutual transformation of
- java.text.ParseException: Unparseable date: “2021-06-24“
- In pandas, dataframe and np.array The mutual transformation between the two
- Jsonformat annotation solves the problem of time format in the front end of localdatetime
- Get the current date in Python
- Linux view current date and time
- [JS] use date. Now(). Tostring() to generate serial number
- [BUG-mybatis-plus] org.postgresql.util.PSQLException: ERROR: syntax error at or near “current_date“
- Ecarts comes with the date formatting method formattime
- SAP RETAIL WA01 Creative Distribution List Error – Plant 0000000039 Confirmation date not maintained. –
- Network agent problem: task: preparekotlinbuildscriptmodel up-to-date
- Java lossy conversion
- Failed to convert value of type ‘java.lang.String‘ to required type ‘java.util.Date‘;
- Conversion from hexadecimal to decimal
- ERROR 2026 (HY000): SSL connection error: ASN: before date in the future