简体   繁体   English

从jDateChooser更改月份格式

[英]change Month format from jDateChooser

how to change month format in jDateChooser ? 如何更改jDateChooser中的月份格式? this is my code : 这是我的代码:

    private DateFormat df = DateFormat.getDateInstance();

    private void jButtonInsertActionPerformed(java.awt.event.ActionEvent evt) { 
            String x = df.format(jDateChooser.getDate());
            showtable(x); // this method for showing Date to jTable 
    }

example output : 04 Mar 15, and I want to change Month name "Mar" to "03", but don't know how to change it. 示例输出:04 Mar 15,我想将月份名称“ Mar”更改为“ 03”,但不知道如何更改。 Please help 请帮忙

Use the SimpleDataFormat class instead 改用SimpleDataFormat类

http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

Replace this 取代这个

private DateFormat df = DateFormat.getDateInstance();

with this 有了这个

private SimpleDateFormat df = SimpleDateFormat("dd MM yy");

You can customise any format you want here 您可以在此处自定义所需的任何格式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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