从 jDateChooser 更改月份格式

change Month format from jDateChooser

如何更改 jDateChooser 中的月份格式? 这是我的代码:

    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 
    }

示例输出:15 年 3 月 4 日,我想将月份名称 "Mar" 更改为“03”,但不知道如何更改。请帮忙

改为使用 SimpleDateFormat class

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

替换这个

private DateFormat df = DateFormat.getDateInstance();

有了这个

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

您可以在此处自定义您想要的任何格式