Example usage for org.joda.time Period getHours

List of usage examples for org.joda.time Period getHours

Introduction

In this page you can find the example usage for org.joda.time Period getHours.

Prototype

public int getHours() 

Source Link

Document

Gets the hours field part of the period.

Usage

From source file:nz.co.gregs.dbvolution.internal.datatypes.DateRepeatImpl.java

License:Apache License

/**
 *
 * @param interval//from w  w w . jav  a2 s.co  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: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.apereo.portlet.hr.timereporting.util.TimeCalculations.java

License:Apache License

public static String convertPeriodToHHMM(Period period) {
    Period timeStandardized = period.normalizedStandard(PeriodType.time());
    return getDoubleDigit(timeStandardized.getHours()) + ":" + getDoubleDigit(timeStandardized.getMinutes());
}

From source file:org.ash.gui.ASHrawdata.java

License:Open Source License

/**
 * Get period in mm, dd, hh, ss//from w  w w.  j a v a  2  s  .c o 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;
}

From source file:org.ash.history.CalendarH.java

License:Open Source License

/**
 * Get period between start and end date from BDB
 * /*from   w  w w  .j  a va 2s .co m*/
 * @return
 */
private String getPeriodBDB() {
    String out = "";
    DateTime start = new DateTime(getStartBDB());
    DateTime end = new DateTime(getEndBDB());

    Period period = new Period(start, end);

    if (period.getMonths() > 0)
        out = period.getMonths() + " month(s) ";
    if (period.getDays() > 0)
        out = out + period.getDays() + " day(s) ";
    if (period.getHours() > 0)
        out = out + period.getHours() + " hour(s) ";
    if (period.getMinutes() > 0)
        out = out + period.getMinutes() + " minute(s) ";

    return out;
}

From source file:org.ash.util.Utils.java

License:Open Source License

public static String getTimeFormatting(double intervalSec) {
    String out = "";

    // Exit when intervalSec == 0
    if (intervalSec == 0.0) {
        return out;
    }//from w ww.  j  a v  a 2  s. com

    DateTime start = new DateTime(0);
    DateTime end = new DateTime((long) (intervalSec * 1000));
    Period period = new Period(start, end);

    String hours = "";
    String minutes = "";
    String secunds = "";

    if (period.getHours() < 10) {
        hours = "0" + period.getHours();
    } else {
        hours = "" + period.getHours();
    }
    if (period.getMinutes() < 10) {
        minutes = "0" + period.getMinutes();
    } else {
        minutes = "" + period.getMinutes();
    }
    if (period.getSeconds() < 10) {
        secunds = "0" + period.getSeconds();
    } else {
        secunds = "" + period.getSeconds();
    }

    out = hours + ":" + minutes + ":" + secunds;

    return out;
}

From source file:org.bhave.experiment.run.GUIConsole.java

public void updateProgress(final Period remaining, final int value, final int currentRun, final int totalRuns) {
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {

            progress.setValue(value);//from  w  w  w.j  av  a  2 s.c o m

            progress.setString("estimated time remaining: " + String.format("%02d:%02d:%02d",
                    remaining.getHours(), remaining.getMinutes(), remaining.getSeconds()));

            notification.append("completed run: " + currentRun + " / " + totalRuns + "\n");

        }
    });
}

From source file:org.dungeon.io.SavesTableWriter.java

License:Open Source License

private static String makePeriodString(long start, long end) {
    Period period = new Period(start, end);
    TimeStringBuilder builder = new TimeStringBuilder();
    builder.set(EarthTimeUnit.YEAR, period.getYears());
    builder.set(EarthTimeUnit.MONTH, period.getMonths());
    builder.set(EarthTimeUnit.DAY, period.getDays());
    builder.set(EarthTimeUnit.HOUR, period.getHours());
    builder.set(EarthTimeUnit.MINUTE, period.getMinutes());
    builder.set(EarthTimeUnit.SECOND, period.getSeconds());
    return builder.toString(2) + " ago";
}