`

获取今天的开始时间和结束时间

 
阅读更多
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,S");

Calendar todayStart = Calendar.getInstance();
todayStart.set(Calendar.HOUR, 0);
todayStart.set(Calendar.MINUTE, 0);
todayStart.set(Calendar.SECOND, 0);
todayStart.set(Calendar.MILLISECOND, 0);

System.out.println(sf.format(todayStart.getTime()));

Calendar todayEnd = Calendar.getInstance();
todayEnd.set(Calendar.HOUR, 23);
todayEnd.set(Calendar.MINUTE, 59);
todayEnd.set(Calendar.SECOND, 59);
todayEnd.set(Calendar.MILLISECOND, 999);

System.out.println(sf.format(todayEnd.getTime()));

/* output
2010-04-30 00:00:00,0
2010-04-30 23:59:59,999
*/
 
0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics