SimpleDateFormat sdf = new SimpleDateFormat("MMMM yyyy", Locale.ENGLISH);
System.out.println(sdf.format(new Date()));
System.out.println(sdf.format(new Date().getTime()));
--------------------------
April 2013
April 2013
本文介绍了如何使用Java中的SimpleDateFormat类来格式化日期。通过设置特定的模式,可以将日期对象转换为指定格式的字符串。示例展示了如何将当前日期格式化为'MMMMyyyy'的形式。
SimpleDateFormat sdf = new SimpleDateFormat("MMMM yyyy", Locale.ENGLISH);
System.out.println(sdf.format(new Date()));
System.out.println(sdf.format(new Date().getTime()));
--------------------------
April 2013
April 2013
368

被折叠的 条评论
为什么被折叠?