6

开始日期与结束日期的用法

 3 years ago
source link: http://www.blogjava.net/paulwong/archive/2020/12/29/435759.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

开始日期与结束日期的用法

通常要用到取某个时间段内的数据,那么时间段要如何定义?
取2020-12-01这天的数据,"2020-12-01 00:00:00" <= time < "2020-12-02 00:00:00"。
apache common3中提供了相应的方法:
startDate = DateUtils.parseDate(startDateStr, DATE_PATTERN);

String endDateStr = args.getOptionValues(END_DATE).get(0);
endDate = DateUtils.parseDate(endDateStr, DATE_PATTERN);

//清零开始日期,返回类似2020-12-01 00:00:00            
startDate = DateUtils.truncate(startDate, Calendar.DATE);
//取结束日期的上限,返回隔天的时间,2020-12-02 00:00:00
endDate = DateUtils.ceiling(endDate, Calendar.DATE);"。
apache common3中提供了相应的方法:

posted on 2020-12-29 10:37 paulwong 阅读(20) 评论(0)  编辑  收藏 所属分类: J2SE


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK