List of usage examples for java.util Date after
public boolean after(Date when)
From source file:com.bibisco.manager.TipManager.java
private static boolean getDonationTip(Properties lProperties) { if (lProperties.getValue() == "false") { return false; }/*w w w.ja v a 2 s .com*/ // it's first time... else if (StringUtils.isEmpty(lProperties.getValue())) { String lStrDate = mDateFormat.format(new Date()); SqlSessionFactory lSqlSessionFactory = SqlSessionFactoryManager.getInstance() .getSqlSessionFactoryBibisco(); SqlSession lSqlSession = lSqlSessionFactory.openSession(); try { PropertiesMapper lPropertiesMapper = lSqlSession.getMapper(PropertiesMapper.class); Properties lPropertiesToInsert = new Properties(); lPropertiesToInsert.setProperty("donationTip"); lPropertiesToInsert.setValue(lStrDate); lPropertiesMapper.updateByPrimaryKey(lPropertiesToInsert); lSqlSession.commit(); } catch (Throwable t) { mLog.error(t); lSqlSession.rollback(); throw new BibiscoException(t, BibiscoException.SQL_EXCEPTION); } finally { lSqlSession.close(); } return false; } else { try { Date lDate = mDateFormat.parse(lProperties.getValue()); Date lDateNow = new Date(); if (lDateNow.after(DateUtils.addDays(lDate, 30))) { return true; } else { return false; } } catch (ParseException e) { mLog.error(e); return false; } } }
From source file:gov.nasa.arc.spife.ui.table.days.Day.java
public static boolean extentsIntersect(TemporalExtent dayExtent, TemporalExtent elementExtent) { Date dayStart = dayExtent.getStart(); Date elementEnd = elementExtent.getEnd(); if (elementEnd.before(dayStart)) { return false; }/*from www . ja va 2s . c o m*/ Date elementStart = elementExtent.getStart(); Date dayEnd = dayExtent.getEnd(); if (elementStart.after(dayEnd)) { return false; } if (elementEnd.equals(dayStart) && !elementStart.equals(dayStart)) { return false; } return true; }
From source file:net.paissad.waqtsalat.utils.geoip.GeoipHelper.java
/** * Verify whether or not an update is available for the specified GEOIP * resource.//from ww w. j av a2 s. c o m * <p> * <b>Note</b>:If the local file does not exist yet, then an update is * supposed to be automatically available. * </p> * * @param type * @param localFile * - The local file to use while comparing timestamps. * @return <tt>true</tt> if an update is available, <tt>false</tt> * otherwise. * * @see GEOIPTYPE */ public static boolean isUpdateAvailable(GEOIPTYPE type, final File localFile) { /* * TODO: instead of relying on the presence and timestamp of the local * file, the datas should be stored into a database. It's safer. * In other words, the timestamp of 'eventual' previous dates of updates * should be saved into a database/table. */ logger.info("Checking GeoIP update for {}.", type.toString()); String url = null; if (type == GEOIPTYPE.DATABASE) { url = GEOIP_DATABASE_UPDATE_URL; } else if (type == GEOIPTYPE.WORLD_CITIES) { url = GEOIP_WORLDCITIES_URL; } if (!localFile.exists()) { return true; } Date localDate = new Date(localFile.lastModified()); Date remoteDate = new Date(CommonUtils.getRemoteTimestamp(url)); return remoteDate.after(localDate); }
From source file:com.augmentum.common.util.DateUtil.java
public static boolean isBetweenTime(Date date, String start, String end) { boolean isTime = false; if ((date != null) && StringUtils.isNotBlank(start) && StringUtils.isNotBlank(end)) { Date startDate = getDateFromStr(start); Date endDate = getDateFromStr(end); if (endDate.after(startDate)) { if ((date.compareTo(startDate) >= 0) && (date.compareTo(endDate) <= 0)) { isTime = true;/*from w w w . j a v a 2 s . c o m*/ } } } return isTime; }
From source file:Main.java
public static String getDateFormattedRecent(Date date, int daysAgo) { //display day of the week for activities occurred in the last daysAgo Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, 0 - daysAgo); Date weekAgo = calendar.getTime(); if (date.after(weekAgo)) { return new SimpleDateFormat("EEE").format(date);//EEE, short version of day of the week }/*w w w. j ava 2 s . co m*/ //otherwise, display the date of the activity else { return new SimpleDateFormat("MM.dd.yy").format(date); } }
From source file:com.vmware.identity.rest.core.server.util.VerificationUtil.java
/** * Verifies the request was issued within a certain amount of skew. * * @param context the request context to verify * @param skew the amount of skew to allow in milliseconds * @param log a logger to log the error to * * @return true if the request time is valid, false otherwise *//*from w w w . j a v a2s . com*/ public static boolean verifyRequestTime(ContainerRequestContext context, long skew, IDiagnosticsLogger log) { long currentTime = System.currentTimeMillis(); Date beginsAt = new Date(currentTime - skew); Date expiresAt = new Date(currentTime + skew); Date requestTime = context.getDate(); if (requestTime.before(beginsAt) || requestTime.after(expiresAt)) { log.error(String.format( "Request time outside of acceptable range. Request time: '%s'. Acceptable range: ['%s', '%s']", requestTime, beginsAt, expiresAt)); return false; } return true; }
From source file:com.inkubator.common.util.DateTimeUtil.java
/** * get total times (Age) based on date parameter * * @param birthDate input date type/* w ww . j av a2 s . co m*/ * @return Integer age that calculate from today * @throws java.lang.Exception * */ public static Integer getAge(Date birthDate) throws Exception { if (birthDate.after(new Date())) { throw new Exception("Mr DHFR say :Your birthdate is newer than to day. Can't be born in the future!"); } else { DateMidnight date1 = new DateMidnight(birthDate); DateTime now = new DateTime(); Years years = Years.yearsBetween(date1, now); return years.getYears(); } }
From source file:com.inkubator.common.util.DateTimeUtil.java
/** * get total Day between two date//from ww w . j ava2 s .com * * @param startDate Date reference * @return Integer * @param endDate Date reference * @throws java.lang.Exception */ public static Integer getTotalDay(Date startDate, Date endDate) throws Exception { if (startDate.after(endDate)) { throw new Exception("Mr. DHFR say :End Date must be newer than Start Date"); } else { return getTotalDayDifference(startDate, endDate) + 1; } }
From source file:Main.java
public static String calculateAge(Context context, String date) { final String FACEBOOK = "MM/dd/yyyy"; try {// w w w .ja v a 2 s. c om SimpleDateFormat sf = new SimpleDateFormat(FACEBOOK, Locale.ENGLISH); sf.setLenient(true); Date birthDate = sf.parse(date); Date now = new Date(); int age = now.getYear() - birthDate.getYear(); birthDate.setHours(0); birthDate.setMinutes(0); birthDate.setSeconds(0); birthDate.setYear(now.getYear()); if (birthDate.after(now)) { age -= 1; } return Integer.toString(age); } catch (Exception e) { Log.d("DEBUG", "exception in getTwitterDate:"); e.printStackTrace(); return "Unknown"; } }
From source file:com.app.util.UserUtil.java
public static void resetPassword(String emailAddress, String password, String passwordResetToken) throws Exception { User user = getUserByEmailAddress(emailAddress); Timestamp passwordResetExpiration = user.getPasswordResetExpiration(); Date date = new Date(); if (date.after(passwordResetExpiration) || !user.getPasswordResetToken().equals(passwordResetToken)) { throw new PasswordResetException(); } else {/* w w w . j ava 2 s . com*/ updatePassword(user.getUserId(), password); } }