dd / mm / yyyy和dd / mm / yyyy? [英] dd/mm/yyyy vs dd/MM/yyyy?

查看:95
本文介绍了dd / mm / yyyy和dd / mm / yyyy?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
        String date = sdf.format(new Date()); 
        System.out.println(date); 

结果是今天的日期,即2014年3月23日

Result is todays date i.e 23/03/2014

但是当我这样做

 SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy"); 

结果可以是2014年5月23日,2014年5月23日,2014年6月23日以及每次prgram运行的儿子。为什么这样?

result can be 23/05/2014, 23/05/2014, 23/06/2014 and son with each run of prgram. Why so?

推荐答案

我们从文档,这是因为 mm 是几分钟而不是几个月。

As we can see from the documentation, it's because mm is for minutes, not months.

这篇关于dd / mm / yyyy和dd / mm / yyyy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆