How to convert from Instant to LocalDate

前端 未结 5 845
旧巷少年郎
旧巷少年郎 2020-12-14 06:10

I have an Instant coming from a source that should, according to the spec, be a LocalDate, but don\'t see any methods in LocalDate for the conversion. What is the best way t

5条回答
  •  渐次进展
    2020-12-14 06:31

    If using java 8 you can do the following

    Instant instantOfNow = Instant.now();
    LocalDate localDate 
        = LocalDateTime.ofInstant(instantOfNow, ZoneOffset.UTC).toLocalDate();
    

提交回复
热议问题