SimpleDateFormat中m和M不能混用

在上传文件时,为了避免文件重复,就以时间为文件名建立文,误将M与m混用了,导致文件夹的目录结构不对

实践一下:

before:

new SimpleDateFormat("yyyy/mm/dd/HH").format(new Date())

after:

new SimpleDateFormat("yyyy/MM/dd/HH").format(new Date())

实际上M才是月,m是分钟

我们可以实践一下:

before:(北京时间2018/11/17/13/30)

after:(北京时间2018/11/17/13/30)

猜你喜欢

转载自blog.csdn.net/zhou_438/article/details/84182990
M
^M
今日推荐