Example usage for org.joda.time.field FieldUtils safeNegate

List of usage examples for org.joda.time.field FieldUtils safeNegate

Introduction

In this page you can find the example usage for org.joda.time.field FieldUtils safeNegate.

Prototype

public static int safeNegate(int value) 

Source Link

Document

Negates the input throwing an exception if it can't negate it.

Usage

From source file:net.sourceforge.fenixedu.util.HourMinuteSecond.java

License:Open Source License

/**
 * Returns a new datetime minus the specified number of hours.
 * <p>/*from   w w  w. ja  va2s .  c  o m*/
 * This datetime instance is immutable and unaffected by this method call.
 * <p>
 * The following three lines are identical in effect:
 * 
 * <pre>
 * HourMinuteSecond subtracted = hms.minusHours(6);
 * 
 * HourMinuteSecond subtracted = hms.minus(Period.hours(6));
 * 
 * HourMinuteSecond subtracted = hms.withFieldAdded(DurationFieldType.hours(), -6);
 * </pre>
 * 
 * @param hours
 *            the amount of hours to subtract, may be negative
 * @return the new datetime minus the increased hours
 */
public HourMinuteSecond minusHours(int hours) {
    return withFieldAdded(DurationFieldType.hours(), FieldUtils.safeNegate(hours));
}

From source file:net.sourceforge.fenixedu.util.HourMinuteSecond.java

License:Open Source License

/**
 * Returns a new datetime minus the specified number of minutes.
 * <p>//from ww  w  .  java  2s.  com
 * This datetime instance is immutable and unaffected by this method call.
 * <p>
 * The following three lines are identical in effect:
 * 
 * <pre>
 * HourMinuteSecond subtracted = hms.minusMinutes(6);
 * 
 * HourMinuteSecond subtracted = hms.minus(Period.minutes(6));
 * 
 * HourMinuteSecond subtracted = hms.withFieldAdded(DurationFieldType.minutes(), -6);
 * </pre>
 * 
 * @param minutes
 *            the amount of minutes to subtract, may be negative
 * @return the new datetime minus the increased minutes
 */
public HourMinuteSecond minusMinutes(int minutes) {
    return withFieldAdded(DurationFieldType.minutes(), FieldUtils.safeNegate(minutes));
}

From source file:net.sourceforge.fenixedu.util.HourMinuteSecond.java

License:Open Source License

/**
 * Returns a new datetime minus the specified number of seconds.
 * <p>/*from w w  w  . j a  v  a2 s . c o  m*/
 * This datetime instance is immutable and unaffected by this method call.
 * <p>
 * The following three lines are identical in effect:
 * 
 * <pre>
 * HourMinuteSecond subtracted = hms.minusSeconds(6);
 * 
 * HourMinuteSecond subtracted = hms.minus(Period.seconds(6));
 * 
 * HourMinuteSecond subtracted = hms.withFieldAdded(DurationFieldType.seconds(), -6);
 * </pre>
 * 
 * @param seconds
 *            the amount of seconds to subtract, may be negative
 * @return the new datetime minus the increased seconds
 */
public HourMinuteSecond minusSeconds(int seconds) {
    return withFieldAdded(DurationFieldType.seconds(), FieldUtils.safeNegate(seconds));
}