Java8 java.util.Date conversion to java.time.ZonedDateTime

后端 未结 4 696
轮回少年
轮回少年 2020-12-07 21:44

I am getting the following exception while trying to convert java.util.Date to java.time.LocalDate.

java.time.DateTimeException: U         


        
4条回答
  •  伪装坚强ぢ
    2020-12-07 22:28

    To obtain a ZonedDateTime from a Date you can use:

    calculateFromDate.toInstant().atZone(ZoneId.systemDefault())
    

    You can then call the toLocalDate method if you need a LocalDate. See also: Convert java.util.Date to java.time.LocalDate

提交回复
热议问题