List of usage examples for org.apache.commons.lang3.time DateUtils truncate
public static Date truncate(final Object date, final int field)
Truncates a date, leaving the field specified as the most significant field.
For example, if you had the date-time of 28 Mar 2002 13:45:01.231, if you passed with HOUR, it would return 28 Mar 2002 13:00:00.000.
From source file:com.googlecode.commons.swing.util.DateUtils2.java
public static Date getStartOfMonth(Date month) { if (month == null) { return null; }//from w w w . j a va 2s .co m Date start = (Date) month.clone(); start = DateUtils.truncate(start, Calendar.MONTH); return start; }
From source file:com.googlecode.commons.swing.util.DateUtils2.java
public static Date getEndOfMonth(Date month) { if (month == null) { return null; }/*from w w w .j a v a 2s .co m*/ Date end = (Date) month.clone(); end = DateUtils.truncate(end, Calendar.MONTH); end = DateUtils.addMonths(end, 1); end = DateUtils.addMilliseconds(end, -1); return end; }
From source file:com.alibaba.utils.date.CommonDateUtils.java
/** * <pre>// w w w.j a v a 2 s . c o m * * : * 2013.09.202 * 2013.09.18, 2013.09.19, 2013.09.20 * </pre> * @param currentDate * @param days * @return */ public static List<Date> beforeCurrentDate(Date currentDate, int days) { List<Date> dateList = new ArrayList<Date>(); // 0. if (currentDate == null) { return null; } if (days <= 0) { dateList.add(DateUtils.truncate(currentDate, Calendar.DAY_OF_MONTH)); return dateList; } // 1. Date startDate = DateUtils.addDays(currentDate, 0 - days); for (int i = 0; i < days; ++i) { Date date = DateUtils.addDays(startDate, i); // dateList.add(DateUtils.truncate(date, Calendar.DAY_OF_MONTH)); } // 2. dateList.add(DateUtils.truncate(currentDate, Calendar.DAY_OF_MONTH)); return dateList; }
From source file:com.bjond.utilities.DateTimeUtils.java
/** * Returns 00:01:01.000 in the morning of Date. * * @param date Valid non-null java.util.Date object * @return New date. Original is not altered. *///from w w w .j av a2s . co m public static Date getStartOfDay(final Date date) { return DateUtils.truncate(date, Calendar.DATE); }
From source file:com.saax.gestorweb.util.DAOAleatorio.java
public static Date getDataByOffset(int offsetDataAtual, boolean up) { GregorianCalendar gc = new GregorianCalendar(); Date hoje = DateUtils.truncate(new Date(), Calendar.DATE); gc.setTime(hoje); // hoje truncando as horas for (int i = 0; i < offsetDataAtual; i++) { gc.roll(GregorianCalendar.DAY_OF_MONTH, up); if (gc.getActualMaximum(GregorianCalendar.DAY_OF_MONTH) == gc.get(GregorianCalendar.DAY_OF_MONTH)) { gc.roll(GregorianCalendar.MONTH, up); }//from w w w.java 2 s .c om } return DateUtils.truncate(new Date(gc.getTimeInMillis()), Calendar.DATE); }
From source file:love.sola.netsupport.api.API.java
public static Date getToday() { return DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH); }
From source file:com.bellman.bible.service.readingplan.ReadingPlanInfoDto.java
public void setStartToJan1() { Date jan1 = DateUtils.truncate(new Date(), Calendar.YEAR); startOn(jan1, true); }
From source file:love.sola.netsupport.api.API.java
public static Date getDay(Date date) { return DateUtils.truncate(date, Calendar.DAY_OF_MONTH); }
From source file:io.lavagna.model.EventsCount.java
public EventsCount(@Column("EVENT_DATE") Date date, @Column("EVENT_COUNT") long count) { this.date = DateUtils.truncate(date, Calendar.DATE).getTime(); this.count = count; }
From source file:io.lavagna.model.StatisticsResult.java
public StatisticsResult(@Column("TIME") Date date, @Column("BOARD_COLUMN_DEFINITION_VALUE") ColumnDefinition columnDefinition, @Column("STATISTICS_COUNT") long count) { this.day = DateUtils.truncate(date, Calendar.DATE).getTime(); this.columnDefinition = columnDefinition; this.count = count; }