List of usage examples for java.util Date after
public boolean after(Date when)
From source file:com.intuit.tank.persistence.databases.MetricsCalculator.java
private boolean skipDate(Date date, Date start, Date end) { boolean ret = false; if (start != null && date.before(start)) { ret = true;/*from www. j a v a 2s . com*/ } else if (end != null && date.after(end)) { ret = true; } return ret; }
From source file:com.epam.ta.reportportal.database.dao.DashboardRepositoryTest.java
@Test public void testFindAll() { Sort creationDateSort = new Sort(new Order(Direction.DESC, Dashboard.CREATION_DATE)); List<Dashboard> dashboards = dashboardRepository.findAll(BuilderTestsConstants.USER, creationDateSort, BuilderTestsConstants.PROJECT); Assert.assertEquals(dashboards.size(), 4); Date currentDate = null; for (Dashboard dashboard : dashboards) { if (currentDate == null) { currentDate = dashboard.getCreationDate(); } else {// ww w .j av a 2 s . com Assert.assertTrue(currentDate.after(dashboard.getCreationDate())); currentDate = dashboard.getCreationDate(); } Assert.assertNotNull(dashboard.getAcl().getOwnerUserId()); Assert.assertNotNull(dashboard.getWidgets()); } Assert.assertTrue( dashboardRepository.findAll(BuilderTestsConstants.USER, creationDateSort, "1").size() == 0); Assert.assertTrue( dashboardRepository.findAll("1", creationDateSort, BuilderTestsConstants.PROJECT).size() == 0); }
From source file:com.huateng.ebank.framework.util.DateUtil.java
/** * (?)// www . j a v a 2s.c o m * * @param startDate * @param endDate * @return */ public static int getActualMonths(Date startDate, Date endDate) { Calendar calendarStartDate = Calendar.getInstance(); Calendar calendarEndDate = Calendar.getInstance(); // calendarStartDate.setTime(startDate); calendarEndDate.setTime(endDate); if (startDate.after(endDate)) { Calendar swap = calendarStartDate; calendarStartDate = calendarEndDate; calendarEndDate = swap; } int months = calendarEndDate.get(Calendar.MONTH) - calendarStartDate.get(Calendar.MONTH) + (calendarEndDate.get(Calendar.YEAR) - calendarStartDate.get(Calendar.YEAR)) * 12; return months; }
From source file:com.apigee.sdk.apm.http.impl.client.cache.CacheEntryUpdater.java
private boolean entryDateHeaderNewerThenResponse(HttpCacheEntry entry, HttpResponse response) { try {//from w ww .j a va 2 s. co m Date entryDate = DateUtils.parseDate(entry.getFirstHeader(HTTP.DATE_HEADER).getValue()); Date responseDate = DateUtils.parseDate(response.getFirstHeader(HTTP.DATE_HEADER).getValue()); if (!entryDate.after(responseDate)) { return false; } } catch (DateParseException e) { return false; } return true; }
From source file:com.huateng.ebank.framework.util.DateUtil.java
/** * (?)// w ww . j a va 2s .c om * * @param startDate * @param endDate * @return */ public static int getMonthsBetween(Date startDate, Date endDate) { Calendar calendarStartDate = Calendar.getInstance(); Calendar calendarEndDate = Calendar.getInstance(); // calendarStartDate.setTime(startDate); calendarEndDate.setTime(endDate); if (startDate.after(endDate)) { Calendar swap = calendarStartDate; calendarStartDate = calendarEndDate; calendarEndDate = swap; } int months = calendarEndDate.get(Calendar.MONTH) - calendarStartDate.get(Calendar.MONTH) + (calendarEndDate.get(Calendar.YEAR) - calendarStartDate.get(Calendar.YEAR)) * 12; if (getEndDateByMonths(startDate, months).compareTo(endDate) < 0) months += 1; return months; }
From source file:com.huateng.ebank.framework.util.DateUtil.java
/** * (??1)//from w w w.j a v a 2 s. com */ public static int getActualMonths2(Date startDate, Date endDate) { Calendar calendarStartDate = Calendar.getInstance(); Calendar calendarEndDate = Calendar.getInstance(); // calendarStartDate.setTime(startDate); calendarEndDate.setTime(endDate); if (startDate.after(endDate)) { Calendar swap = calendarStartDate; calendarStartDate = calendarEndDate; calendarEndDate = swap; } int months = calendarEndDate.get(Calendar.MONTH) - calendarStartDate.get(Calendar.MONTH) + (calendarEndDate.get(Calendar.YEAR) - calendarStartDate.get(Calendar.YEAR)) * 12; if (getEndDateByMonths(startDate, months).after(endDate)) months = months - 1; return months; }
From source file:com.huateng.ebank.framework.util.DateUtil.java
/** * /* w w w.j a v a 2 s . co m*/ * * @param startDate * @param endDate * @return */ public static int getDaysBetween(Date startDate, Date endDate) { Calendar calendarStartDate = Calendar.getInstance(); Calendar calendarEndDate = Calendar.getInstance(); // calendarStartDate.setTime(startDate); calendarEndDate.setTime(endDate); if (startDate.after(endDate)) { Calendar swap = calendarStartDate; calendarStartDate = calendarEndDate; calendarEndDate = swap; } int days = calendarEndDate.get(Calendar.DAY_OF_YEAR) - calendarStartDate.get(Calendar.DAY_OF_YEAR); int y2 = calendarEndDate.get(Calendar.YEAR); while (calendarStartDate.get(Calendar.YEAR) < y2) { days += calendarStartDate.getActualMaximum(Calendar.DAY_OF_YEAR); calendarStartDate.add(Calendar.YEAR, 1); } return days; }
From source file:com.huateng.ebank.framework.util.DateUtil.java
/** * ?/*from w w w. j a v a 2 s . c om*/ * * @param startDate * @param endDate * @return */ public static boolean isSameDate(Date startDate, Date endDate) { Calendar calendarStartDate = Calendar.getInstance(); Calendar calendarEndDate = Calendar.getInstance(); // calendarStartDate.setTime(startDate); calendarEndDate.setTime(endDate); if (startDate.after(endDate)) { Calendar swap = calendarStartDate; calendarStartDate = calendarEndDate; calendarEndDate = swap; } if (calendarStartDate.get(Calendar.DATE) == calendarEndDate.get(Calendar.DATE)) return true; if (calendarStartDate.get(Calendar.DATE) > calendarEndDate.get(Calendar.DATE)) { if (calendarEndDate.get(Calendar.DATE) == calendarEndDate.getActualMaximum(Calendar.DATE)) return true; } return false; }
From source file:com.vmware.identity.session.Session.java
/** * @return check if the is expired/*w w w .j a v a 2s . co m*/ */ public boolean isValid() { Calendar calendar = new GregorianCalendar(); Date currentTime = calendar.getTime(); if (currentTime.after(expireDate)) { return false; } return true; }
From source file:com.google.sampling.experiential.android.lib.GoogleAccountLoginHelper.java
private boolean isPacoAuthCookieSetAndValid(String key, String expiry) { if (key == null || expiry == null) { return false; }/* www . j a v a 2s . co m*/ try { Date expirationDate = new SimpleDateFormat(Constants.DATE_TIME_FORMAT).parse(expiry); return expirationDate.after(new Date()); } catch (ParseException e) { return false; } }