JDK 1.8
DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); LocalDateTime ldt = LocalDateTime.parse("2023-01-01 00:00:00.123", f); System.out.println(ldt.plusNanos(1000000L).format(f)); System.out.println(ldt.plus(1L, ChronoUnit.MILLIS).format(f)); 결과 2023-01-01 00:00:00.124 2023-01-01 00:00:00.124
찾아보니 없어서 직접 질문했다.
https://stackoverflow.com/questions/75866488/localdatetime-add-millisecond
LocalDateTime add millisecond
I want to increase the millisecond value with LocalDateTime. I used plusNanos because I didn't have plusmillisecond. I wonder if this is the right way. I'm using JDK 1.8. I also want to know if the...
stackoverflow.com
toString 사용 시 0이 추가 되는 현상은 SSS, SSSSSS, SSSSSSSSS 으로 지원하기 때문이다.
LocalDateTime.toString - can the format be configured in the environment?
I have code that saves a LocalDateTime as a string using myTime.toString. It gets read back in using a Spring converter to convert from the String to a LocalDateTime. No formatting anywhere, it is ...
stackoverflow.com
'Lang > Java' 카테고리의 다른 글
간단하게 Java synchronized 사용 방법 (0) | 2023.07.01 |
---|---|
밀리세컨드 범위 동적으로 사용 (0) | 2023.05.07 |
Quartz 간단하게 사용법 (0) | 2023.02.18 |
Java ArrayList, Map multiThread (0) | 2023.02.12 |
Thread Runnable 사용 시 setName (0) | 2023.02.11 |