[英]how to display date chosen from java JXDatePicker and how to stored into database?
i have a code like this 我有这样的代码
JXDatePicker picker = new JXDatePicker();
//picker.setDate(Calendar.getInstance().getTime());
picker.setFormats(new SimpleDateFormat("dd.MM.yyyy"));
picker.setDate(Calendar.getInstance().getTime());
picker.setBounds(50,130,100,25);
f.add(picker);
now i want to display date into console how to do this? 现在我想在控制台中显示日期该怎么做?
For displaying date into console you can do the following: 要将日期显示到控制台中,您可以执行以下操作:
SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
picker.setFormats(formatter);
System.out.println(formatter.format(picker.getDate()));
But as @AndrewThompson said, in GUI application, displaying date on console is a bad idea. 但是正如@AndrewThompson所说,在GUI应用程序中,在控制台上显示日期是一个坏主意。 Instead you can show it in a JLabel if you want. 相反,您可以根据需要在JLabel中显示它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.