简体   繁体   中英

java.util.Date to kotlinx.datetime.LocalDateTime

I have a value of type java.util.Date which was obtained from a legacy third-party API. Is there a direct way of converting it to kotlinx.datetime.LocalDateTime ? I know how to do it only in a roundabout way, such as serializing to String and deserializing, or by converting to java.time.LocalDateTime first and then to the wanted type.

i Think the best thing you can do is to convert it to a string and than convert into a kotlinx.datetime.LocalDateTime

The problem is that not all java types can be converted directly into a kotlin one especially not with the old DataType java.util.Date.

It is also posible with the new DataType java.time.LocalDateTime .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM