List of usage examples for java.util Date before
public boolean before(Date when)
From source file:Main.java
/** * This is a helper method for checking if the fromDate is later than the * toDate. This is necessary in case a user sends the dates with HTTP GET. * * @param fromDate//w w w . ja v a2 s . c om * @param toDate * @return boolean */ public static boolean checkDates(String fromDate, String toDate) { String formatString = DEFAULT_DATE_FORMAT; SimpleDateFormat sdf = new SimpleDateFormat(formatString); Date date1 = null; Date date2 = null; try { date1 = sdf.parse(fromDate); date2 = sdf.parse(toDate); } catch (ParseException e) { return false; // The user hasn't specified any dates } if (!date1.before(date2)) { return true; // Return true if date2 is earlier than date1 } else { return false; } }
From source file:com.mycompany.craftdemo.utility.java
public static boolean compareDates(String compare) { try {/*from w w w. ja v a2 s . c om*/ Calendar now = Calendar.getInstance(); SimpleDateFormat inputParser = new SimpleDateFormat("HH:mm", Locale.US); int hour = now.get(Calendar.HOUR_OF_DAY); int minute = now.get(Calendar.MINUTE); Date date = inputParser.parse(hour + ":" + minute); Date dateCompareOne = inputParser.parse(compare); return dateCompareOne.before(date); } catch (java.text.ParseException e) { return false; } }
From source file:com.webbfontaine.valuewebb.model.validators.MpPriceDateValidator.java
public static boolean validate(Date date) { Date todayDate = DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH); Date dateWithoutTime = DateUtils.truncate(date, Calendar.DAY_OF_MONTH); return date == null || Integer.parseInt(new SimpleDateFormat("yyyy").format(date)) >= 2010 && !todayDate.before(dateWithoutTime); }
From source file:com.projity.util.DateTime.java
public static Date min(Date date1, Date date2) { return date1.before(date2) ? date1 : date2; }
From source file:gov.nih.nci.firebird.data.AbstractCredential.java
static boolean isExpired(Date expirationDate) { if (expirationDate == null) { return false; }//from w w w. ja v a 2 s . c o m Date today = DateUtils.truncate(new Date(), Calendar.MONTH); Date expires = DateUtils.truncate(expirationDate, Calendar.MONTH); return expires.before(today); }
From source file:eu.ggnet.dwoss.report.assist.ReportUtil.java
/** * Returns all Lines of the Report for Category Invoiced, split by mfgDate - startOfReport < 1 year and the rest. * This consists of:// w ww. j a va2 s .c om * <ul> * <li>Position of Type Invoice, with no References</li> * <li>Position of Type UNIT_ANNEX in DocumentType CREDIT_MEMO/ANNULATIION_INVOICE and a Referencing Invoice in the same report.</li> * </ul> * <p> * It's not allowed to have a null value in the collection. * <p> * @param lines * @param startingDate * @return all Lines of the Report for Category Invoiced. */ public static YearSplit filterInvoicedSplit(Collection<ReportLine> lines, Date startingDate) { NavigableSet<ReportLine> pastSplit = new TreeSet<>(); NavigableSet<ReportLine> preSplit = new TreeSet<>(); Date splitter = DateUtils.addYears(startingDate, -1); for (ReportLine line : filterInvoiced(lines)) { if (splitter.before(line.getMfgDate())) { preSplit.add(line); } else { pastSplit.add(line); } } return new YearSplit(startingDate, preSplit, pastSplit); }
From source file:byku.traindroid.DataFacade.java
public static void ClearTimeTable(Boolean all) { if (all) {//from ww w.j a va2 s. c o m _timeTables.clear(); return; } Date today = Utils.Today(); for (int i = 0; i < _timeTables.size(); ++i) { Date date = Utils.StringToDate(_timeTables.get(i).getDate(), true); if (date.before(today)) { _timeTables.remove(i); --i; } } }
From source file:net.kamhon.ieagle.util.DateUtil.java
/** * Return those date in dates which is between fromDate and toDate. * /* w w w .ja va2 s. c o m*/ * @return */ public static List<Date> getDateBetween(List<Date> dates, Date fromDate, Date toDate) { List<Date> retDateList = new ArrayList<Date>(); for (Date date : dates) { if (fromDate.equals(date) || toDate.equals(date) || date.after(fromDate) && date.before(toDate)) { retDateList.add(date); } } if (retDateList.size() > 1) { Collections.sort(retDateList); } return retDateList; }
From source file:jp.terasoluna.fw.util.DateUtil.java
/** * ??????/* w ww . jav a 2s .c o m*/ * * <p> * ???ApplicationResources ?? * </p> * * @param date * @return ? */ public static String getWarekiGengoName(Date date) { for (int i = GENGO_BEGIN_DATES.length - 1; i >= 0; i--) { if (!date.before(GENGO_BEGIN_DATES[i])) { return GENGO_NAME.get(GENGO_BEGIN_DATES[i]); } } throw new IllegalArgumentException("Wareki Gengo Name not found for " + date); }
From source file:jp.terasoluna.fw.util.DateUtil.java
/** * ???????//from w w w . j ava 2 s . com * * <p>????ApplicationResources??</p> * * @param date * @return ?? */ public static String getWarekiGengoRoman(Date date) { for (int i = GENGO_BEGIN_DATES.length - 1; i >= 0; i--) { if (!date.before(GENGO_BEGIN_DATES[i])) { return GENGO_ROMAN.get(GENGO_BEGIN_DATES[i]); } } throw new IllegalArgumentException("Wareki Gengo Roman not found for " + date); }