将java.time.LocalDate转换为java.util.Date类型 [英] Convert java.time.LocalDate into java.util.Date type
本文介绍了将java.time.LocalDate转换为java.util.Date类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想转换 java.time.LocalDate
进入 java.util.Date
类型。因为我想将日期设置为 JDateChooser
。或者是否有任何支持 java的日期选择器。时间
日期?
I want to convert java.time.LocalDate
into java.util.Date
type. Because I want to set the date into JDateChooser
. Or is there any date chooser that supports java.time
dates?
推荐答案
Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
假设您的日期选择器使用系统默认时区将日期转换为字符串。
That assumes your date chooser uses the system default timezone to transform dates into strings.
这篇关于将java.time.LocalDate转换为java.util.Date类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文