List of usage examples for org.joda.time Period getSeconds
public int 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: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++;/* w w w. ja v a2s . com*/ } 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:nu.yona.app.utils.AppUtils.java
/** * Gets time for otp./*from w ww .j a v a 2 s.com*/ * * @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); }
From source file:nz.co.gregs.dbvolution.databases.definitions.DBDefinition.java
License:Apache License
/** * Creates a string representation of a DateRepeat from the Period * * @param interval the interval to be transformed into a DateRepeat. * @return a DateRpeat as an SQL string/*ww w .j a v a 2s . co m*/ */ public String transformPeriodIntoDateRepeat(Period interval) { StringBuilder str = new StringBuilder(); str.append("'").append(DateRepeatExpression.INTERVAL_PREFIX); str.append(interval.getYears()).append(DateRepeatExpression.YEAR_SUFFIX); str.append(interval.getMonths()).append(DateRepeatExpression.MONTH_SUFFIX); str.append(interval.getDays() + (interval.getWeeks() * 7)).append(DateRepeatExpression.DAY_SUFFIX); str.append(interval.getHours()).append(DateRepeatExpression.HOUR_SUFFIX); str.append(interval.getMinutes()).append(DateRepeatExpression.MINUTE_SUFFIX); str.append(interval.getSeconds()).append(DateRepeatExpression.SECOND_SUFFIX); str.append("'"); return str.toString(); }
From source file:nz.co.gregs.dbvolution.internal.datatypes.DateRepeatImpl.java
License:Apache License
/** * * @param interval/* ww w . ja v a 2 s. c o m*/ * @return the DateRepeat equivalent of the Period value */ public static String getDateRepeatString(Period interval) { if (interval == null) { return null; } int years = interval.getYears(); int months = interval.getMonths(); int days = interval.getDays() + interval.getWeeks() * 7; int hours = interval.getHours(); int minutes = interval.getMinutes(); int millis = interval.getMillis(); double seconds = interval.getSeconds() + (millis / 1000.0); String intervalString = "P" + years + "Y" + months + "M" + days + "D" + hours + "h" + minutes + "n" + seconds + "s"; return intervalString; }
From source file:Objects.Game.java
public int getTimeSpent() { Period timeElapsed = new Period(this.startTime, new DateTime()); return timeElapsed.getSeconds(); }
From source file:org.adempierelbr.util.AdempiereLBR.java
License:Open Source License
public static String executionTime(long start, long end) { Period period = new Period(start, end); String tempo = TextUtil.lPad(period.getHours(), 2) + ":" + TextUtil.lPad(period.getMinutes(), 2) + ":" + TextUtil.lPad(period.getSeconds(), 2); return tempo; }
From source file:org.apache.arrow.vector.util.DateUtility.java
License:Apache License
public static int millisFromPeriod(final Period period) { return (period.getHours() * hoursToMillis) + (period.getMinutes() * minutesToMillis) + (period.getSeconds() * secondsToMillis) + (period.getMillis()); }
From source file:org.apache.drill.exec.vector.DateUtilities.java
License:Apache License
public static int periodToMillis(final Period period) { return (period.getHours() * hoursToMillis) + (period.getMinutes() * minutesToMillis) + (period.getSeconds() * secondsToMillis) + (period.getMillis()); }
From source file:org.ash.gui.ASHrawdata.java
License:Open Source License
/** * Get period in mm, dd, hh, ss/*w w w . ja v a 2 s . co m*/ * @param begind * @param endd * @return */ private String getPeriod(double begind, double endd) { String out = ""; Double beginD = begind; Double endD = endd; DateTime start = new DateTime(beginD.longValue()); DateTime end = new DateTime(endD.longValue()); Period period = new Period(start, end); if (period.getMonths() > 0) out = period.getMonths() + " m. "; if (period.getDays() > 0) out = out + period.getDays() + " d. "; if (period.getHours() > 0) out = out + period.getHours() + " h. "; if (period.getMinutes() > 0) out = out + period.getMinutes() + " min. "; if (period.getSeconds() > 0) out = out + period.getSeconds() + " sec. "; return out; }