List of usage examples for com.google.gwt.user.datepicker.client CalendarUtil setToFirstDayOfMonth
@SuppressWarnings("deprecation") public static void setToFirstDayOfMonth(Date date)
From source file:org.jbpm.console.ng.gc.client.util.DateUtils.java
License:Apache License
/** * Returns a {@link DateRange} starting on first day of month in which the specified date is and ending on last day of that * month.//from ww w .ja v a2 s . c o m * * @param date date from which to get the month date range * @return {@link DateRange} representing the month in which the specified date is */ @SuppressWarnings("deprecation") public static DateRange getMonthDateRange(Date date) { Date startDate = new Date(date.getTime()); CalendarUtil.setToFirstDayOfMonth(startDate); // the above method will set hours to 12 startDate.setHours(0); Date endDate = new Date(date.getTime()); CalendarUtil.setToFirstDayOfMonth(endDate); CalendarUtil.addMonthsToDate(endDate, 1); CalendarUtil.addDaysToDate(endDate, -1); endDate.setHours(0); return new DateRange(startDate, endDate, CalendarUtil.getDaysBetween(startDate, endDate)); }
From source file:org.jbpm.console.ng.gc.client.util.DateUtils.java
License:Apache License
@SuppressWarnings("deprecation") public static Date getSameOrClosestDateInPreviousMonth(Date date) { Date desiredDate = new Date(date.getTime()); CalendarUtil.addMonthsToDate(desiredDate, -1); if (desiredDate.getMonth() == date.getMonth()) { // did not go one month back // e.g. 31 May -> 1st May, because April does not have 31st and thus the day is set to 1st May CalendarUtil.setToFirstDayOfMonth(desiredDate); CalendarUtil.addDaysToDate(desiredDate, -1); }//from w ww .j a va 2 s . c o m return desiredDate; }
From source file:org.jbpm.console.ng.gc.client.util.DateUtils.java
License:Apache License
@SuppressWarnings("deprecation") public static Date getSameOrClosestDateInNextMonth(Date date) { Date desiredDate = new Date(date.getTime()); CalendarUtil.addMonthsToDate(desiredDate, 1); if (desiredDate.getMonth() > date.getMonth() + 1) { // skipped one month, e.g. 30 January -> 2nd (or 1st for leap-year) March, because February does not have 30th // set the date to last day of previous month CalendarUtil.setToFirstDayOfMonth(desiredDate); CalendarUtil.addDaysToDate(desiredDate, -1); }//from w w w. jav a 2 s . c o m return desiredDate; }
From source file:org.jbpm.console.ng.ht.client.util.DateUtils.java
License:Apache License
/** * Returns a {@link DateRange} starting on first day of month in which the specified date is and ending on last day of that * month./*from w w w. ja va 2 s . c o m*/ * * @param date date from which to get the mont date range * @return {@link DateRange} representing the month in which the specified date is */ @SuppressWarnings("deprecation") public static DateRange getMonthDateRange(Date date) { Date startDate = new Date(date.getTime()); CalendarUtil.setToFirstDayOfMonth(startDate); // the above method will set hours to 12 startDate.setHours(0); Date endDate = new Date(date.getTime()); CalendarUtil.setToFirstDayOfMonth(endDate); CalendarUtil.addMonthsToDate(endDate, 1); CalendarUtil.addDaysToDate(endDate, -1); endDate.setHours(0); return new DateRange(startDate, endDate); }
From source file:org.jbpm.workbench.common.client.util.DateUtils.java
License:Apache License
/** * Returns a {@link DateRange} starting on first day of month in which the specified date is and ending on last day of that * month./* w ww. ja v a2 s . co m*/ * @param date date from which to get the month date range * @return {@link DateRange} representing the month in which the specified date is */ @SuppressWarnings("deprecation") public static DateRange getMonthDateRange(Date date) { Date startDate = new Date(date.getTime()); CalendarUtil.setToFirstDayOfMonth(startDate); // the above method will set hours to 12 startDate.setHours(0); Date endDate = new Date(date.getTime()); CalendarUtil.setToFirstDayOfMonth(endDate); CalendarUtil.addMonthsToDate(endDate, 1); CalendarUtil.addDaysToDate(endDate, -1); endDate.setHours(0); return new DateRange(startDate, endDate); }
From source file:org.obiba.opal.web.gwt.app.client.magma.derive.view.DeriveTemporalVariableStepView.java
License:Open Source License
public DeriveTemporalVariableStepView() { widget = uiBinder.createAndBindUi(this); fromDate.setFormat("yyyy-mm-dd"); Date now = new Date(); CalendarUtil.addDaysToDate(now, -3650); CalendarUtil.setToFirstDayOfMonth(now); fromDate.setValue(now);//from ww w . ja v a2 s.c o m fromDate.setWidth("6em"); toDate.setFormat("yyyy-mm-dd"); now = new Date(); toDate.setValue(now); toDate.setWidth("6em"); spanRadio.setValue(true, true); }
From source file:pl.datamatica.traccar.model.Period.java
License:Apache License
static Date firstDayOfMonth(Date date) { CalendarUtil.setToFirstDayOfMonth(date); return date; }