List of usage examples for org.joda.time Period getMinutes
public int getMinutes()
From source file:gov.nih.nci.cadsr.cadsrpasswordchange.core.MainServlet.java
License:BSD License
private boolean isAnswerLockPeriodOver(String userID) throws Exception { boolean retVal = false; logger.debug("isAnswerLockExpired:entered"); connect();/*from ww w . j a v a2 s . c om*/ PasswordChangeDAO dao = new PasswordChangeDAO(datasource); logger.debug("isAnswerLockExpired:before dao.findByPrimaryKey userid [" + userID + "]"); UserSecurityQuestion qna = dao.findByPrimaryKey(userID); logger.debug("isAnswerLockExpired:qna [" + qna + "]"); if (qna != null) { logger.debug("isAnswerLockExpired:qna not null [" + qna.toString() + "]"); if (qna.getDateModified() == null) { throw new Exception("Security questions date modified is NULL or empty."); } DateTime now = new DateTime(); logger.debug( "isAnswerLockExpired:last modified date for user '" + userID + "' is " + qna.getDateModified()); Period period = new Period(new DateTime(qna.getDateModified()), now); if (period.getHours() >= 1) { //CADSRPASSW-51 retVal = true; logger.info("isAnswerLockExpired:Over 1 hour for user '" + userID + "', answer limit count reset (" + period.getMinutes() + " minutes has passed)."); } else { logger.debug("isAnswerLockExpired:Not over 1 hour yet for user '" + userID + "', nothing is done (" + period.getMinutes() + " minutes has passed)."); } } logger.debug("isAnswerLockExpired:exiting ..."); return retVal; }
From source file:influent.server.utilities.DateTimeParser.java
License:MIT License
/** * @see http://joda-time.sourceforge.net/apidocs/org/joda/time/Period.html#normalizedStandard() *//* www .ja v a 2 s . c o m*/ public static Period normalize(Period period) { long millis = period.getMillis(); millis += period.getSeconds() * DateTimeConstants.MILLIS_PER_SECOND; millis += period.getMinutes() * DateTimeConstants.MILLIS_PER_MINUTE; millis += period.getHours() * DateTimeConstants.MILLIS_PER_HOUR; millis += period.getDays() * DateTimeConstants.MILLIS_PER_DAY; millis += period.getWeeks() * DateTimeConstants.MILLIS_PER_WEEK; Period result = new Period(millis, DateTimeUtils.getPeriodType(PeriodType.standard()), ISOChronology.getInstanceUTC()); int years = period.getYears(); int months = period.getMonths(); if (years != 0 || months != 0) { years = FieldUtils.safeAdd(years, months / 12); months = months % 12; if (years != 0) { result = result.withYears(years); } if (months != 0) { result = result.withMonths(months); } } return result; }
From source file:io.coala.xml.XmlUtil.java
License:Apache License
/** * @param period//from ww w .ja v a 2 s . co m * @return a JAXP {@link Duration} */ public static Duration toDuration(final Period period) { return getDatatypeFactory().newDuration(true, period.getYears(), period.getMonths(), period.getDays(), period.getHours(), period.getMinutes(), period.getSeconds()); }
From source file:io.druid.sql.calcite.expression.builtin.TimeFloorOperatorConversion.java
License:Apache License
private static boolean periodIsDayMultiple(final Period period) { return period.getMillis() == 0 && period.getSeconds() == 0 && period.getMinutes() == 0 && period.getHours() == 0 && (period.getDays() > 0 || period.getWeeks() > 0 || period.getMonths() > 0 || period.getYears() > 0); }
From source file:io.ehdev.android.drivingtime.view.dialog.InsertOrEditRecordDialog.java
License:Open Source License
private void setTimeViewParameters(View view) { Period duration = drivingRecord.getDurationOfDriving().toPeriod(); ((TimePicker) view.findViewById(R.id.durationPicker)).setIs24HourView(true); ((TimePicker) view.findViewById(R.id.durationPicker)).setCurrentHour(duration.getHours()); ((TimePicker) view.findViewById(R.id.durationPicker)).setCurrentMinute(duration.getMinutes()); }
From source file:io.ehdev.android.drivingtime.view.dialog.InsertOrEditTaskDialog.java
License:Open Source License
private void setTimeViewParameters(View view) { Period duration = drivingTask.getRequiredHours().toPeriod(); ((TimePicker) view.findViewById(R.id.durationPicker)).setIs24HourView(true); ((TimePicker) view.findViewById(R.id.durationPicker)).setCurrentHour(duration.getHours()); ((TimePicker) view.findViewById(R.id.durationPicker)).setCurrentMinute(duration.getMinutes()); }
From source file:net.longfalcon.view.DateView.java
License:Open Source License
public Period roundPeriod(Period period) { int fieldCount = 0; int years = period.getYears(); int months = period.getMonths(); int weeks = period.getWeeks(); int days = period.getDays(); int hours = period.getHours(); int minutes = period.getMinutes(); int seconds = period.getSeconds(); if (years > 0) { fieldCount++;//from ww w . j a va2 s . co m } if (months > 0) { fieldCount++; } if (fieldCount > 1) { return new Period(years, months, 0, 0, 0, 0, 0, 0); } if (weeks > 0) { fieldCount++; } if (fieldCount > 1) { return new Period(0, months, weeks, 0, 0, 0, 0, 0); } if (days > 0) { fieldCount++; } if (fieldCount > 1) { return new Period(0, 0, weeks, days, 0, 0, 0, 0); } if (hours > 0) { fieldCount++; } if (fieldCount > 1) { return new Period(0, 0, 0, days, hours, 0, 0, 0); } if (minutes > 0) { fieldCount++; } if (fieldCount > 1) { return new Period(0, 0, 0, 0, hours, minutes, 0, 0); } return new Period(0, 0, 0, 0, 0, minutes, seconds, 0); }
From source file:net.longfalcon.web.AdminJobConfigController.java
License:Open Source License
private JobConfigView getJobConfigView(JobConfig jobConfig) { JobConfigView jobConfigView = new JobConfigView(); jobConfigView.setJobKey(jobConfig.getJobName()); String jobFrequency = jobConfig.getJobFrequency(); jobConfigView.setFrequencyType(jobFrequency); if (JobConfigKeys.FREQ_PERIODIC.equals(jobFrequency)) { int periodMillis = Integer.parseInt(jobConfig.getFrequencyConfig()); Period period = new Period(periodMillis); jobConfigView.setPeriodHours(period.getHours()); jobConfigView.setPeriodMins(period.getMinutes()); } else if (JobConfigKeys.FREQ_SCHEDULED.equals(jobFrequency)) { String crontab = jobConfig.getFrequencyConfig(); String[] cronElements = crontab.split(" "); // there will be six. String minutesString = cronElements[1]; jobConfigView.setScheduledMinutes(Integer.parseInt(minutesString)); String hoursString = cronElements[2]; jobConfigView.setScheduledHours(Integer.parseInt(hoursString)); // skip the others right now String days = cronElements[5]; // days are always set as comma list in Newsj. String[] dayList = days.split(","); for (String dayString : dayList) { if ("1".equals(dayString)) { jobConfigView.setSunday(true); }//from w w w . j a v a 2 s .co m if ("2".equals(dayString)) { jobConfigView.setMonday(true); } if ("3".equals(dayString)) { jobConfigView.setTuesday(true); } if ("4".equals(dayString)) { jobConfigView.setWednesday(true); } if ("5".equals(dayString)) { jobConfigView.setThursday(true); } if ("6".equals(dayString)) { jobConfigView.setFriday(true); } if ("7".equals(dayString)) { jobConfigView.setSaturday(true); } } } return jobConfigView; }
From source file:net.mobid.codetraq.persistence.ServerRevision.java
License:Open Source License
/** * Calculates and returns the number of minutes since last monitor. * @return number of minutes elapsed since last monitor *//*from w w w. j av a 2 s. c om*/ public int getMinutesSinceLastCheck() { if (getLastCheckedTimestamp() > 0) { Period p = new Period(getLastCheckedTimestamp(), System.currentTimeMillis()); return p.getMinutes(); } return Integer.MAX_VALUE; }
From source file:nu.yona.app.utils.AppUtils.java
/** * Gets time for otp./*from w w w.j av a 2 s . c om*/ * * @param time the time * @return the time for otp */ public static Pair<String, Long> getTimeForOTP(String time) { try { StringBuffer buffer = new StringBuffer(); long totalTime = 0; Period period = new Period(time); if (period.getHours() > 0) { totalTime += period.getHours() * AppConstant.ONE_SECOND * 60 * 60; buffer.append(YonaApplication.getAppContext().getString(R.string.hours, period.getHours() + "")); } if (period.getMinutes() > 0) { totalTime += period.getMinutes() * AppConstant.ONE_SECOND * 60; buffer.append(YonaApplication.getAppContext().getString(R.string.minute, period.getMinutes() + "")); } if (period.getSeconds() > 0) { totalTime += period.getSeconds() * AppConstant.ONE_SECOND; buffer.append( YonaApplication.getAppContext().getString(R.string.seconds, period.getSeconds() + "")); } return Pair.create(buffer.toString(), totalTime); } catch (Exception e) { AppUtils.reportException(AppUtils.class.getSimpleName(), e, Thread.currentThread()); } return Pair.create(time, (long) 0); }