如何将字符串(日期)格式化为Java中的新日期格式?

如何将字符串(日期)格式化为Java中的新日期格式?,java,date,simpledateformat,Java,Date,Simpledateformat,我会直截了当的,我的目标会改变的 2018-05-24 进入 2018年5月24日 这是我目前的代码: String content = "2018-05-24"; SimpleDateFormat old = new SimpleDateFormat("yyyy-mm-dd"); Date oldDate = old.parse(content); SimpleDateFormat current = new SimpleDateFormat("MMMM dd,

我会直截了当的,我的目标会改变的

2018-05-24

进入

2018年5月24日

这是我目前的代码:

    String content = "2018-05-24";
    SimpleDateFormat old = new SimpleDateFormat("yyyy-mm-dd");
    Date oldDate = old.parse(content);
    SimpleDateFormat current = new SimpleDateFormat("MMMM dd, yyyy.");
    String newDate = current.format(oldDate);
    System.out.println(newDate);
但是跑步会产生:

2018年1月24日


我不知道为什么这会告诉我一月。我知道我搞错了,我在StackOverFlow搜索过类似的问题,但也许我做的事情不对。有什么建议吗?

这是因为您使用
mm
的月份应该是
mm

SimpleDateFormat old = new SimpleDateFormat("yyyy-MM-dd");
这将产生:

May 24, 2018.

非常感谢。我犯了这么愚蠢的错误。