`

SimpleDateFormat 时间操作【原创】

 
阅读更多
SimpleDateFormat sdf = new SimpleDateFormat();
Date d = new Date();

sdf.applyPattern("yyyyMMddHHmmss");
sdf.format(d)

sdf.applyPattern("HHmmss");
sdf.format(d)

sdf.applyPattern("yyyyMMdd");
sdf.format(d)

或者:
SimpleDateFormat sdf1  = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat sdf2  = new SimpleDateFormat("HHmmss");

sdf1.format(new Date())
sdf2.format(new Date())
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics