Java将CST的时间字符串转换成需要的日期格式字符串

 

已知得到的Date类型的变量meettingdate 的值为Sun Dec 16 10:56:34 CST ;现在要将它改为yyyy-MM-dd类型或yyyy年MM月dd日;

变为yyyy年MM月dd日:

SimpleDateFormat dsf = new SimpleDateFormat("yyyy年MM月dd日");

String dateF = dsf.format(meettingdate);

System.out.println(formatStr);

 

变为yyyy-MM-dd:

SimpleDateFormat dsf = new SimpleDateFormat("yyyy-MM-dd");

String dateF = dsf.format(meettingdate);

System.out.println(formatStr);

其他用法参考:SimpleDateFormat的一些常用用法

posted @ 2018-12-19 18:09  xh_Blog  阅读(2086)  评论(0编辑  收藏  举报