- SimpleDateFormatformatter=newSimpleDateFormat("yyyy年MM月dd日HH:mm:ss");
- DatecurDate=newDate(System.currentTimeMillis());//获取当前时间
- Stringstr=formatter.format(curDate);
------------------------------------------------------------------华丽的分割线----------------------------------------------------
- SimpleDateFormatsDateFormat=newSimpleDateFormat("yyyy-MM-ddhh:mm:ss");
- Stringdate=sDateFormat.format(newjava.util.Date());
------------------------------------------------------------------华丽的分割线----------------------------------------------------
- SimpleDateFormatsdf=newSimpleDateFormat("yyyy-MM");
- Stringdate=sdf.format(newjava.util.Date());
-------------------------------------------------------------------华丽的分割线---------------------------------------------------
- df=DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL,Locale.CHINA);
- System.out.println(df.format(newDate()));
本文介绍了Java中使用SimpleDateFormat类进行日期时间格式化的多种方法,包括获取当前完整日期时间、年月、时分秒,并提供了针对不同需求的示例代码。


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



