/** * Returns true if the date has an associated time. * * @param date Date value to check. * @return True if the date has a time component. */ public static boolean hasTime(Date date) { if (date == null) { return false; } long time1 = date.getTime(); long time2 = stripTime(date).getTime(); return time1 != time2; // Do not use "Date.equals" since date may be of type Timestamp. }
/** * Returns the current date in standard format. * * @return Timestamp for current date. */ public String getTimestamp() { return DateUtil.formatDate(DateUtil.stripTime(new Date())); }
/** * Returns a date with the current day (no time). * * @return Current date. */ public static Date today() { return stripTime(now()); }
/** * Update the datebox with the new value. * * @param date New date value. */ private void updateDatebox(Date date) { datebox.setValue(DateUtil.stripTime(date)); }
/** * Sets the UI to reflect the specified time. * * @param datebox The date box. * @param timebox The time box. * @param value Time value to set. */ public static void setTime(Datebox datebox, Timebox timebox, Date value) { value = value == null ? new Date() : value; datebox.setValue(DateUtil.stripTime(value)); timebox.setValue(value); }
/** * Returns a date/time from the UI. This is combined from two UI input elements, one for date * and one for time. * * @param datebox The date box. * @param timebox The time box. * @return The combined date/time. */ public static Date getTime(Datebox datebox, Timebox timebox) { if (timebox.getValue() == null || datebox.getValue() == null) { return DateUtil.stripTime(datebox.getValue()); } Calendar date = Calendar.getInstance(); Calendar time = Calendar.getInstance(); date.setTime(datebox.getValue()); time.setTime(timebox.getValue()); time.set(date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DAY_OF_MONTH)); return time.getTime(); }
/** * Filter result based on selected date range. */ @Override public boolean include(T result) { return getDateRange().inRange(DateUtil.stripTime(dateTypeExtractor.getDateByType(result, dateType)), true, true); }
private Date today() { return DateUtil.stripTime(now()); }