如何在JDateChooser字段上打印DD / MM / YYYY?

时间:2013-11-13 07:05:12

标签: java swing jdatechooser

如何在DD/MM/YYYY字段上打印JDateChooser

JDateChooser jdc=new JDateChooser();

我使用JDateChooser来选择日期,但我也希望以DD/MM/YYYY格式提供类型日期。

enter image description here

3 个答案:

答案 0 :(得分:4)

答案 1 :(得分:1)

api开始,我将使用JDateChooser(java.lang.String dateFormatString,boolean startEmpty)构造函数;

JDateChooser jdc = new JDateChooser("DD/MM/YYYY", true);

答案 2 :(得分:0)

如果要在jdatechooser字段上显示DD / MM / YYYY日期格式,请使用

jDateChooser1.setDateFormatString("dd/MM/yyyy");

当您使用dd / MM / YYYY格式的 getdate()打印日期时,您可以使用

 SimpleDateFormat geekonjavadate = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
 String gojdate = geekonjavadate .format(jDateChooser1.getDate());
 JOptionPane.showMessageDialog(null, "Your selected date is "+gojdate);