Example usage for org.joda.time LocalTime plusMinutes

List of usage examples for org.joda.time LocalTime plusMinutes

Introduction

In this page you can find the example usage for org.joda.time LocalTime plusMinutes.

Prototype

public LocalTime plusMinutes(int minutes) 

Source Link

Document

Returns a copy of this time plus the specified number of minutes.

Usage

From source file:org.pidome.misc.utils.TimeUtils.java

License:Apache License

/**
 * Calculates time difference base on minutes or hours.
 * Given a military time string with -10m or +10h it will return the time corresponding to this calculation
 * @param origTime The original time military format
 * @param differ This only takes whole military time notation including + or - signs: +00:10,+10:00,-01:26,-01:00
 * @return //from  w w  w .j a v  a2  s .  c o  m
 */
public static String calcTimeDiff(String origTime, String differ) {
    LocalTime time = dateTimeFormatter.parseLocalTime(origTime);
    LocalTime differTime = dateTimeFormatter.parseLocalTime(differ.substring(1));
    LocalTime differStartTime = dateTimeFormatter.parseLocalTime("00:00");
    Long duration = new Duration(differStartTime.getMillisOfDay(), differTime.getMillisOfDay())
            .getStandardMinutes();
    if (differ.startsWith("-")) {
        return time.minusMinutes(duration.intValue()).toString(DateTimeFormat.forPattern("HH:mm"));
    } else if (differ.startsWith("+")) {
        return time.plusMinutes(duration.intValue()).toString(DateTimeFormat.forPattern("HH:mm"));
    }
    return origTime;
}