SimpleDateFormat.parse返回无效日期

时间:2017-01-02 08:44:37

标签: java simpledateformat

我发送有效日期(“1705”)并获得不同的解析日期(“1701”)

有关修复内容的任何帮助? 中间的打印显示有效日期。

            SimpleDateFormat sdf = new SimpleDateFormat("YYMM");
            System.out.println(exYear+exMonth);
            Date ccDate = sdf.parse(exYear+exMonth);

1 个答案:

答案 0 :(得分:7)

y年份必须是小案

SimpleDateFormat sdf = new SimpleDateFormat("yyMM");

请参阅javadoc

中的完整符号说明
相关问题