idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
32,600
public void setStart ( ReadableInstant start ) { long startMillis = DateTimeUtils . getInstantMillis ( start ) ; super . setInterval ( startMillis , getEndMillis ( ) , getChronology ( ) ) ; }
Sets the start of this time interval as an Instant .
32,601
public void setEnd ( ReadableInstant end ) { long endMillis = DateTimeUtils . getInstantMillis ( end ) ; super . setInterval ( getStartMillis ( ) , endMillis , getChronology ( ) ) ; }
Sets the end of this time interval as an Instant .
32,602
public void setDurationAfterStart ( ReadableDuration duration ) { long durationMillis = DateTimeUtils . getDurationMillis ( duration ) ; setEndMillis ( FieldUtils . safeAdd ( getStartMillis ( ) , durationMillis ) ) ; }
Sets the duration of this time interval preserving the start instant .
32,603
public void setDurationBeforeEnd ( ReadableDuration duration ) { long durationMillis = DateTimeUtils . getDurationMillis ( duration ) ; setStartMillis ( FieldUtils . safeAdd ( getEndMillis ( ) , - durationMillis ) ) ; }
Sets the duration of this time interval preserving the end instant .
32,604
public void setPeriodAfterStart ( ReadablePeriod period ) { if ( period == null ) { setEndMillis ( getStartMillis ( ) ) ; } else { setEndMillis ( getChronology ( ) . add ( period , getStartMillis ( ) , 1 ) ) ; } }
Sets the period of this time interval preserving the start instant and using the ISOChronology in the default zone for calculations .
32,605
public void setPeriodBeforeEnd ( ReadablePeriod period ) { if ( period == null ) { setStartMillis ( getEndMillis ( ) ) ; } else { setStartMillis ( getChronology ( ) . add ( period , getEndMillis ( ) , - 1 ) ) ; } }
Sets the period of this time interval preserving the end instant and using the ISOChronology in the default zone for calculations .
32,606
public static void appendPaddedInteger ( Appendable appenadble , int value , int size ) throws IOException { if ( value < 0 ) { appenadble . append ( '-' ) ; if ( value != Integer . MIN_VALUE ) { value = - value ; } else { for ( ; size > 10 ; size -- ) { appenadble . append ( '0' ) ; } appenadble . append ( "" + - ( long ) Integer . MIN_VALUE ) ; return ; } } if ( value < 10 ) { for ( ; size > 1 ; size -- ) { appenadble . append ( '0' ) ; } appenadble . append ( ( char ) ( value + '0' ) ) ; } else if ( value < 100 ) { for ( ; size > 2 ; size -- ) { appenadble . append ( '0' ) ; } int d = ( ( value + 1 ) * 13421772 ) >> 27 ; appenadble . append ( ( char ) ( d + '0' ) ) ; appenadble . append ( ( char ) ( value - ( d << 3 ) - ( d << 1 ) + '0' ) ) ; } else { int digits ; if ( value < 1000 ) { digits = 3 ; } else if ( value < 10000 ) { digits = 4 ; } else { digits = ( int ) ( Math . log ( value ) / LOG_10 ) + 1 ; } for ( ; size > digits ; size -- ) { appenadble . append ( '0' ) ; } appenadble . append ( Integer . toString ( value ) ) ; } }
Converts an integer to a string prepended with a variable amount of 0 pad characters and appends it to the given appendable .
32,607
public static void appendUnpaddedInteger ( StringBuffer buf , int value ) { try { appendUnpaddedInteger ( ( Appendable ) buf , value ) ; } catch ( IOException e ) { } }
Converts an integer to a string and appends it to the given buffer .
32,608
public static int calculateDigitCount ( long value ) { if ( value < 0 ) { if ( value != Long . MIN_VALUE ) { return calculateDigitCount ( - value ) + 1 ; } else { return 20 ; } } return ( value < 10 ? 1 : ( value < 100 ? 2 : ( value < 1000 ? 3 : ( value < 10000 ? 4 : ( ( int ) ( Math . log ( value ) / LOG_10 ) + 1 ) ) ) ) ) ; }
Calculates the number of decimal digits for the given value including the sign .
32,609
public static JulianChronology getInstance ( DateTimeZone zone , int minDaysInFirstWeek ) { if ( zone == null ) { zone = DateTimeZone . getDefault ( ) ; } JulianChronology chrono ; JulianChronology [ ] chronos = cCache . get ( zone ) ; if ( chronos == null ) { chronos = new JulianChronology [ 7 ] ; JulianChronology [ ] oldChronos = cCache . putIfAbsent ( zone , chronos ) ; if ( oldChronos != null ) { chronos = oldChronos ; } } try { chrono = chronos [ minDaysInFirstWeek - 1 ] ; } catch ( ArrayIndexOutOfBoundsException e ) { throw new IllegalArgumentException ( "Invalid min days in first week: " + minDaysInFirstWeek ) ; } if ( chrono == null ) { synchronized ( chronos ) { chrono = chronos [ minDaysInFirstWeek - 1 ] ; if ( chrono == null ) { if ( zone == DateTimeZone . UTC ) { chrono = new JulianChronology ( null , null , minDaysInFirstWeek ) ; } else { chrono = getInstance ( DateTimeZone . UTC , minDaysInFirstWeek ) ; chrono = new JulianChronology ( ZonedChronology . getInstance ( chrono , zone ) , null , minDaysInFirstWeek ) ; } chronos [ minDaysInFirstWeek - 1 ] = chrono ; } } } return chrono ; }
Gets an instance of the JulianChronology in the given time zone .
32,610
public void printTo ( StringBuffer buf , ReadablePeriod period ) { checkPrinter ( ) ; checkPeriod ( period ) ; getPrinter ( ) . printTo ( buf , period , iLocale ) ; }
Prints a ReadablePeriod to a StringBuffer .
32,611
public void printTo ( Writer out , ReadablePeriod period ) throws IOException { checkPrinter ( ) ; checkPeriod ( period ) ; getPrinter ( ) . printTo ( out , period , iLocale ) ; }
Prints a ReadablePeriod to a Writer .
32,612
public String print ( ReadablePeriod period ) { checkPrinter ( ) ; checkPeriod ( period ) ; PeriodPrinter printer = getPrinter ( ) ; StringBuffer buf = new StringBuffer ( printer . calculatePrintedLength ( period , iLocale ) ) ; printer . printTo ( buf , period , iLocale ) ; return buf . toString ( ) ; }
Prints a ReadablePeriod to a new String .
32,613
public MutablePeriod parseMutablePeriod ( String text ) { checkParser ( ) ; MutablePeriod period = new MutablePeriod ( 0 , iParseType ) ; int newPos = getParser ( ) . parseInto ( period , text , 0 , iLocale ) ; if ( newPos >= 0 ) { if ( newPos >= text . length ( ) ) { return period ; } } else { newPos = ~ newPos ; } throw new IllegalArgumentException ( FormatUtils . createErrorMessage ( text , newPos ) ) ; }
Parses a period from the given text returning a new MutablePeriod .
32,614
public boolean isSupported ( DurationFieldType type ) { if ( type == null ) { return false ; } DurationField field = type . getField ( getChronology ( ) ) ; if ( DATE_DURATION_TYPES . contains ( type ) || field . getUnitMillis ( ) >= getChronology ( ) . days ( ) . getUnitMillis ( ) ) { return field . isSupported ( ) ; } return false ; }
Checks if the duration type specified is supported by this local date and chronology .
32,615
public static LimitChronology getInstance ( Chronology base , ReadableDateTime lowerLimit , ReadableDateTime upperLimit ) { if ( base == null ) { throw new IllegalArgumentException ( "Must supply a chronology" ) ; } lowerLimit = lowerLimit == null ? null : lowerLimit . toDateTime ( ) ; upperLimit = upperLimit == null ? null : upperLimit . toDateTime ( ) ; if ( lowerLimit != null && upperLimit != null && ! lowerLimit . isBefore ( upperLimit ) ) { throw new IllegalArgumentException ( "The lower limit must be come before than the upper limit" ) ; } return new LimitChronology ( base , ( DateTime ) lowerLimit , ( DateTime ) upperLimit ) ; }
Wraps another chronology with datetime limits . When withUTC or withZone is called the returned LimitChronology instance has the same limits except they are time zone adjusted .
32,616
public Chronology withZone ( DateTimeZone zone ) { if ( zone == null ) { zone = DateTimeZone . getDefault ( ) ; } if ( zone == getZone ( ) ) { return this ; } if ( zone == DateTimeZone . UTC && iWithUTC != null ) { return iWithUTC ; } DateTime lowerLimit = iLowerLimit ; if ( lowerLimit != null ) { MutableDateTime mdt = lowerLimit . toMutableDateTime ( ) ; mdt . setZoneRetainFields ( zone ) ; lowerLimit = mdt . toDateTime ( ) ; } DateTime upperLimit = iUpperLimit ; if ( upperLimit != null ) { MutableDateTime mdt = upperLimit . toMutableDateTime ( ) ; mdt . setZoneRetainFields ( zone ) ; upperLimit = mdt . toDateTime ( ) ; } LimitChronology chrono = getInstance ( getBase ( ) . withZone ( zone ) , lowerLimit , upperLimit ) ; if ( zone == DateTimeZone . UTC ) { iWithUTC = chrono ; } return chrono ; }
If this LimitChronology has the same time zone as the one given then this is returned . Otherwise a new instance is returned with the limits adjusted to the new time zone .
32,617
public DateTime toDateTime ( DateTimeZone zone ) { Chronology chrono = DateTimeUtils . getChronology ( getChronology ( ) ) ; chrono = chrono . withZone ( zone ) ; return new DateTime ( getMillis ( ) , chrono ) ; }
Get this object as a DateTime using the same chronology but a different zone .
32,618
public MutableDateTime toMutableDateTime ( DateTimeZone zone ) { Chronology chrono = DateTimeUtils . getChronology ( getChronology ( ) ) ; chrono = chrono . withZone ( zone ) ; return new MutableDateTime ( getMillis ( ) , chrono ) ; }
Get this object as a MutableDateTime using the same chronology but a different zone .
32,619
public static EthiopicChronology getInstance ( DateTimeZone zone , int minDaysInFirstWeek ) { if ( zone == null ) { zone = DateTimeZone . getDefault ( ) ; } EthiopicChronology chrono ; EthiopicChronology [ ] chronos = cCache . get ( zone ) ; if ( chronos == null ) { chronos = new EthiopicChronology [ 7 ] ; EthiopicChronology [ ] oldChronos = cCache . putIfAbsent ( zone , chronos ) ; if ( oldChronos != null ) { chronos = oldChronos ; } } try { chrono = chronos [ minDaysInFirstWeek - 1 ] ; } catch ( ArrayIndexOutOfBoundsException e ) { throw new IllegalArgumentException ( "Invalid min days in first week: " + minDaysInFirstWeek ) ; } if ( chrono == null ) { synchronized ( chronos ) { chrono = chronos [ minDaysInFirstWeek - 1 ] ; if ( chrono == null ) { if ( zone == DateTimeZone . UTC ) { chrono = new EthiopicChronology ( null , null , minDaysInFirstWeek ) ; DateTime lowerLimit = new DateTime ( 1 , 1 , 1 , 0 , 0 , 0 , 0 , chrono ) ; chrono = new EthiopicChronology ( LimitChronology . getInstance ( chrono , lowerLimit , null ) , null , minDaysInFirstWeek ) ; } else { chrono = getInstance ( DateTimeZone . UTC , minDaysInFirstWeek ) ; chrono = new EthiopicChronology ( ZonedChronology . getInstance ( chrono , zone ) , null , minDaysInFirstWeek ) ; } chronos [ minDaysInFirstWeek - 1 ] = chrono ; } } } return chrono ; }
Gets an instance of the EthiopicChronology in the given time zone .
32,620
public String getAsText ( int fieldValue , Locale locale ) { return GJLocaleSymbols . forLocale ( locale ) . dayOfWeekValueToText ( fieldValue ) ; }
Get the textual value of the specified time instant .
32,621
public String getAsShortText ( int fieldValue , Locale locale ) { return GJLocaleSymbols . forLocale ( locale ) . dayOfWeekValueToShortText ( fieldValue ) ; }
Get the abbreviated textual value of the specified time instant .
32,622
protected static int between ( ReadableInstant start , ReadableInstant end , DurationFieldType field ) { if ( start == null || end == null ) { throw new IllegalArgumentException ( "ReadableInstant objects must not be null" ) ; } Chronology chrono = DateTimeUtils . getInstantChronology ( start ) ; int amount = field . getField ( chrono ) . getDifference ( end . getMillis ( ) , start . getMillis ( ) ) ; return amount ; }
Calculates the number of whole units between the two specified datetimes .
32,623
public int compareTo ( BaseSingleFieldPeriod other ) { if ( other . getClass ( ) != getClass ( ) ) { throw new ClassCastException ( getClass ( ) + " cannot be compared to " + other . getClass ( ) ) ; } int otherValue = other . getValue ( ) ; int thisValue = getValue ( ) ; if ( thisValue > otherValue ) { return 1 ; } if ( thisValue < otherValue ) { return - 1 ; } return 0 ; }
Compares this period to another object of the same class .
32,624
public long set ( long instant , int era ) { FieldUtils . verifyValueBounds ( this , era , DateTimeConstants . BCE , DateTimeConstants . CE ) ; int oldEra = get ( instant ) ; if ( oldEra != era ) { int year = iChronology . getYear ( instant ) ; return iChronology . setYear ( instant , - year ) ; } else { return instant ; } }
Set the Era component of the specified time instant .
32,625
public DateMidnight withZoneRetainFields ( DateTimeZone newZone ) { newZone = DateTimeUtils . getZone ( newZone ) ; DateTimeZone originalZone = DateTimeUtils . getZone ( getZone ( ) ) ; if ( newZone == originalZone ) { return this ; } long millis = originalZone . getMillisKeepLocal ( newZone , getMillis ( ) ) ; return new DateMidnight ( millis , getChronology ( ) . withZone ( newZone ) ) ; }
Returns a copy of this date with a different time zone preserving the day The returned object will have a local time of midnight in the new zone on the same day as the original instant .
32,626
public int get ( long instant ) { if ( instant >= 0 ) { return ( int ) ( ( instant / getUnitMillis ( ) ) % iRange ) ; } else { return iRange - 1 + ( int ) ( ( ( instant + 1 ) / getUnitMillis ( ) ) % iRange ) ; } }
Get the amount of fractional units from the specified time instant .
32,627
public long addWrapField ( long instant , int amount ) { int thisValue = get ( instant ) ; int wrappedValue = FieldUtils . getWrappedValue ( thisValue , amount , getMinimumValue ( ) , getMaximumValue ( ) ) ; return instant + ( wrappedValue - thisValue ) * getUnitMillis ( ) ; }
Add to the component of the specified time instant wrapping around within that component if necessary .
32,628
private void end ( int count ) { end = System . currentTimeMillis ( ) ; long time = ( end - start ) ; result . time = result . time + time ; result . runs = result . runs + count ; result . avg = ( result . time * 1000000 ) / result . runs ; System . out . print ( "." ) ; }
End the stopwatch and print the result .
32,629
private Chronology selectChronology ( Chronology chrono ) { chrono = DateTimeUtils . getChronology ( chrono ) ; if ( iChrono != null ) { chrono = iChrono ; } if ( iZone != null ) { chrono = chrono . withZone ( iZone ) ; } return chrono ; }
Determines the correct chronology to use .
32,630
public String getIllegalValueAsString ( ) { String value = iStringValue ; if ( value == null ) { value = String . valueOf ( iNumberValue ) ; } return value ; }
Returns the illegal value assigned to the field as a non - null string .
32,631
public void prependMessage ( String message ) { if ( iMessage == null ) { iMessage = message ; } else if ( message != null ) { iMessage = message + ": " + iMessage ; } }
Provide additional detail by prepending a message to the existing message . A colon is separator is automatically inserted between the messages .
32,632
public Chronology withZone ( DateTimeZone zone ) { if ( zone == null ) { zone = DateTimeZone . getDefault ( ) ; } if ( zone == getZone ( ) ) { return this ; } return getInstance ( zone , iCutoverInstant , getMinimumDaysInFirstWeek ( ) ) ; }
Gets the Chronology in a specific time zone .
32,633
static long readMillis ( DataInput in ) throws IOException { int v = in . readUnsignedByte ( ) ; switch ( v >> 6 ) { case 0 : default : v = ( v << ( 32 - 6 ) ) >> ( 32 - 6 ) ; return v * ( 30 * 60000L ) ; case 1 : v = ( v << ( 32 - 6 ) ) >> ( 32 - 30 ) ; v |= ( in . readUnsignedByte ( ) ) << 16 ; v |= ( in . readUnsignedByte ( ) ) << 8 ; v |= ( in . readUnsignedByte ( ) ) ; return v * 60000L ; case 2 : long w = ( ( ( long ) v ) << ( 64 - 6 ) ) >> ( 64 - 38 ) ; w |= ( in . readUnsignedByte ( ) ) << 24 ; w |= ( in . readUnsignedByte ( ) ) << 16 ; w |= ( in . readUnsignedByte ( ) ) << 8 ; w |= ( in . readUnsignedByte ( ) ) ; return w * 1000L ; case 3 : return in . readLong ( ) ; } }
Reads encoding generated by writeMillis .
32,634
public DateTimeZoneBuilder addCutover ( int year , char mode , int monthOfYear , int dayOfMonth , int dayOfWeek , boolean advanceDayOfWeek , int millisOfDay ) { if ( iRuleSets . size ( ) > 0 ) { OfYear ofYear = new OfYear ( mode , monthOfYear , dayOfMonth , dayOfWeek , advanceDayOfWeek , millisOfDay ) ; RuleSet lastRuleSet = iRuleSets . get ( iRuleSets . size ( ) - 1 ) ; lastRuleSet . setUpperLimit ( year , ofYear ) ; } iRuleSets . add ( new RuleSet ( ) ) ; return this ; }
Adds a cutover for added rules . The standard offset at the cutover defaults to 0 . Call setStandardOffset afterwards to change it .
32,635
public DateTimeZoneBuilder addRecurringSavings ( String nameKey , int saveMillis , int fromYear , int toYear , char mode , int monthOfYear , int dayOfMonth , int dayOfWeek , boolean advanceDayOfWeek , int millisOfDay ) { if ( fromYear <= toYear ) { OfYear ofYear = new OfYear ( mode , monthOfYear , dayOfMonth , dayOfWeek , advanceDayOfWeek , millisOfDay ) ; Recurrence recurrence = new Recurrence ( ofYear , nameKey , saveMillis ) ; Rule rule = new Rule ( recurrence , fromYear , toYear ) ; getLastRuleSet ( ) . addRule ( rule ) ; } return this ; }
Add a recurring daylight saving time rule .
32,636
public DateTimeZone toDateTimeZone ( String id , boolean outputID ) { if ( id == null ) { throw new IllegalArgumentException ( ) ; } ArrayList < Transition > transitions = new ArrayList < Transition > ( ) ; DSTZone tailZone = null ; long millis = Long . MIN_VALUE ; int saveMillis = 0 ; int ruleSetCount = iRuleSets . size ( ) ; for ( int i = 0 ; i < ruleSetCount ; i ++ ) { RuleSet rs = iRuleSets . get ( i ) ; Transition next = rs . firstTransition ( millis ) ; if ( next == null ) { continue ; } addTransition ( transitions , next ) ; millis = next . getMillis ( ) ; saveMillis = next . getSaveMillis ( ) ; rs = new RuleSet ( rs ) ; while ( ( next = rs . nextTransition ( millis , saveMillis ) ) != null ) { if ( addTransition ( transitions , next ) && tailZone != null ) { break ; } millis = next . getMillis ( ) ; saveMillis = next . getSaveMillis ( ) ; if ( tailZone == null && i == ruleSetCount - 1 ) { tailZone = rs . buildTailZone ( id ) ; } } millis = rs . getUpperLimit ( saveMillis ) ; } if ( transitions . size ( ) == 0 ) { if ( tailZone != null ) { return tailZone ; } return buildFixedZone ( id , "UTC" , 0 , 0 ) ; } if ( transitions . size ( ) == 1 && tailZone == null ) { Transition tr = transitions . get ( 0 ) ; return buildFixedZone ( id , tr . getNameKey ( ) , tr . getWallOffset ( ) , tr . getStandardOffset ( ) ) ; } PrecalculatedZone zone = PrecalculatedZone . create ( id , outputID , transitions , tailZone ) ; if ( zone . isCachable ( ) ) { return CachedDateTimeZone . forZone ( zone ) ; } return zone ; }
Processes all the rules and builds a DateTimeZone .
32,637
public boolean isSupported ( DurationFieldType type ) { if ( type == null ) { return false ; } return type . getField ( getChronology ( ) ) . isSupported ( ) ; }
Checks if the duration type specified is supported by this local datetime and chronology .
32,638
public static ZonedChronology getInstance ( Chronology base , DateTimeZone zone ) { if ( base == null ) { throw new IllegalArgumentException ( "Must supply a chronology" ) ; } base = base . withUTC ( ) ; if ( base == null ) { throw new IllegalArgumentException ( "UTC chronology must not be null" ) ; } if ( zone == null ) { throw new IllegalArgumentException ( "DateTimeZone must not be null" ) ; } return new ZonedChronology ( base , zone ) ; }
Create a ZonedChronology for any chronology overriding any time zone it may already have .
32,639
private void checkAndUpdate ( DurationFieldType type , int [ ] values , int newValue ) { int index = indexOf ( type ) ; if ( index == - 1 ) { if ( newValue != 0 ) { throw new IllegalArgumentException ( "Period does not support field '" + type . getName ( ) + "'" ) ; } } else { values [ index ] = newValue ; } }
Checks whether a field type is supported and if so adds the new value to the relevant index in the specified array .
32,640
protected void setPeriod ( int years , int months , int weeks , int days , int hours , int minutes , int seconds , int millis ) { int [ ] newValues = setPeriodInternal ( years , months , weeks , days , hours , minutes , seconds , millis ) ; setValues ( newValues ) ; }
Sets the eight standard the fields in one go .
32,641
protected void setFieldInto ( int [ ] values , DurationFieldType field , int value ) { int index = indexOf ( field ) ; if ( index == - 1 ) { if ( value != 0 || field == null ) { throw new IllegalArgumentException ( "Period does not support field '" + field + "'" ) ; } } else { values [ index ] = value ; } }
Sets the value of a field in this period .
32,642
protected void addFieldInto ( int [ ] values , DurationFieldType field , int value ) { int index = indexOf ( field ) ; if ( index == - 1 ) { if ( value != 0 || field == null ) { throw new IllegalArgumentException ( "Period does not support field '" + field + "'" ) ; } } else { values [ index ] = FieldUtils . safeAdd ( values [ index ] , value ) ; } }
Adds the value of a field in this period .
32,643
protected int [ ] mergePeriodInto ( int [ ] values , ReadablePeriod period ) { for ( int i = 0 , isize = period . size ( ) ; i < isize ; i ++ ) { DurationFieldType type = period . getFieldType ( i ) ; int value = period . getValue ( i ) ; checkAndUpdate ( type , values , value ) ; } return values ; }
Merges the fields from another period .
32,644
protected int [ ] addPeriodInto ( int [ ] values , ReadablePeriod period ) { for ( int i = 0 , isize = period . size ( ) ; i < isize ; i ++ ) { DurationFieldType type = period . getFieldType ( i ) ; int value = period . getValue ( i ) ; if ( value != 0 ) { int index = indexOf ( type ) ; if ( index == - 1 ) { throw new IllegalArgumentException ( "Period does not support field '" + type . getName ( ) + "'" ) ; } else { values [ index ] = FieldUtils . safeAdd ( getValue ( index ) , value ) ; } } } return values ; }
Adds the fields from another period .
32,645
static GJLocaleSymbols forLocale ( Locale locale ) { if ( locale == null ) { locale = Locale . getDefault ( ) ; } GJLocaleSymbols symbols = cCache . get ( locale ) ; if ( symbols == null ) { symbols = new GJLocaleSymbols ( locale ) ; GJLocaleSymbols oldSymbols = cCache . putIfAbsent ( locale , symbols ) ; if ( oldSymbols != null ) { symbols = oldSymbols ; } } return symbols ; }
Obtains the symbols for a locale .
32,646
public static int safeAdd ( int val1 , int val2 ) { int sum = val1 + val2 ; if ( ( val1 ^ sum ) < 0 && ( val1 ^ val2 ) >= 0 ) { throw new ArithmeticException ( "The calculation caused an overflow: " + val1 + " + " + val2 ) ; } return sum ; }
Add two values throwing an exception if overflow occurs .
32,647
public static long safeSubtract ( long val1 , long val2 ) { long diff = val1 - val2 ; if ( ( val1 ^ diff ) < 0 && ( val1 ^ val2 ) < 0 ) { throw new ArithmeticException ( "The calculation caused an overflow: " + val1 + " - " + val2 ) ; } return diff ; }
Subtracts two values throwing an exception if overflow occurs .
32,648
public static long safeDivide ( long dividend , long divisor ) { if ( dividend == Long . MIN_VALUE && divisor == - 1L ) { throw new ArithmeticException ( "Multiplication overflows a long: " + dividend + " / " + divisor ) ; } return dividend / divisor ; }
Divides the dividend by the divisor throwing an exception if overflow occurs or the divisor is zero .
32,649
public static long safeDivide ( long dividend , long divisor , RoundingMode roundingMode ) { if ( dividend == Long . MIN_VALUE && divisor == - 1L ) { throw new ArithmeticException ( "Multiplication overflows a long: " + dividend + " / " + divisor ) ; } BigDecimal dividendBigDecimal = new BigDecimal ( dividend ) ; BigDecimal divisorBigDecimal = new BigDecimal ( divisor ) ; return dividendBigDecimal . divide ( divisorBigDecimal , roundingMode ) . longValue ( ) ; }
Divides the dividend by divisor . Rounding of result occurs as per the roundingMode .
32,650
public static int safeMultiplyToInt ( long val1 , long val2 ) { long val = FieldUtils . safeMultiply ( val1 , val2 ) ; return FieldUtils . safeToInt ( val ) ; }
Multiply two values to return an int throwing an exception if overflow occurs .
32,651
public static int getWrappedValue ( int currentValue , int wrapValue , int minValue , int maxValue ) { return getWrappedValue ( currentValue + wrapValue , minValue , maxValue ) ; }
Utility method used by addWrapField implementations to ensure the new value lies within the field s legal value range .
32,652
public static int getWrappedValue ( int value , int minValue , int maxValue ) { if ( minValue >= maxValue ) { throw new IllegalArgumentException ( "MIN > MAX" ) ; } int wrapRange = maxValue - minValue + 1 ; value -= minValue ; if ( value >= 0 ) { return ( value % wrapRange ) + minValue ; } int remByRange = ( - value ) % wrapRange ; if ( remByRange == 0 ) { return 0 + minValue ; } return ( wrapRange - remByRange ) + minValue ; }
Utility method that ensures the given value lies within the field s legal value range .
32,653
private static boolean isNumericToken ( String token ) { int tokenLen = token . length ( ) ; if ( tokenLen > 0 ) { char c = token . charAt ( 0 ) ; switch ( c ) { case 'c' : case 'C' : case 'x' : case 'y' : case 'Y' : case 'd' : case 'h' : case 'H' : case 'm' : case 's' : case 'S' : case 'e' : case 'D' : case 'F' : case 'w' : case 'W' : case 'k' : case 'K' : return true ; case 'M' : if ( tokenLen <= 2 ) { return true ; } } } return false ; }
Returns true if token should be parsed as a numeric field .
32,654
private static DateTimeFormatter createFormatterForPattern ( String pattern ) { if ( pattern == null || pattern . length ( ) == 0 ) { throw new IllegalArgumentException ( "Invalid pattern specification" ) ; } DateTimeFormatter formatter = cPatternCache . get ( pattern ) ; if ( formatter == null ) { DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder ( ) ; parsePatternTo ( builder , pattern ) ; formatter = builder . toFormatter ( ) ; if ( cPatternCache . size ( ) < PATTERN_CACHE_SIZE ) { DateTimeFormatter oldFormatter = cPatternCache . putIfAbsent ( pattern , formatter ) ; if ( oldFormatter != null ) { formatter = oldFormatter ; } } } return formatter ; }
Select a format from a custom pattern .
32,655
private static DateTimeFormatter createFormatterForStyle ( String style ) { if ( style == null || style . length ( ) != 2 ) { throw new IllegalArgumentException ( "Invalid style specification: " + style ) ; } int dateStyle = selectStyle ( style . charAt ( 0 ) ) ; int timeStyle = selectStyle ( style . charAt ( 1 ) ) ; if ( dateStyle == NONE && timeStyle == NONE ) { throw new IllegalArgumentException ( "Style '--' is invalid" ) ; } return createFormatterForStyleIndex ( dateStyle , timeStyle ) ; }
Select a format from a two character style pattern . The first character is the date style and the second character is the time style . Specify a character of S for short style M for medium L for long and F for full . A date or time may be omitted by specifying a style character - .
32,656
private static DateTimeFormatter createFormatterForStyleIndex ( int dateStyle , int timeStyle ) { int index = ( ( dateStyle << 2 ) + dateStyle ) + timeStyle ; if ( index >= cStyleCache . length ( ) ) { return createDateTimeFormatter ( dateStyle , timeStyle ) ; } DateTimeFormatter f = cStyleCache . get ( index ) ; if ( f == null ) { f = createDateTimeFormatter ( dateStyle , timeStyle ) ; if ( cStyleCache . compareAndSet ( index , null , f ) == false ) { f = cStyleCache . get ( index ) ; } } return f ; }
Gets the formatter for the specified style .
32,657
private static DateTimeFormatter createDateTimeFormatter ( int dateStyle , int timeStyle ) { int type = DATETIME ; if ( dateStyle == NONE ) { type = TIME ; } else if ( timeStyle == NONE ) { type = DATE ; } StyleFormatter llf = new StyleFormatter ( dateStyle , timeStyle , type ) ; return new DateTimeFormatter ( llf , llf ) ; }
Creates a formatter for the specified style .
32,658
private static int selectStyle ( char ch ) { switch ( ch ) { case 'S' : return SHORT ; case 'M' : return MEDIUM ; case 'L' : return LONG ; case 'F' : return FULL ; case '-' : return NONE ; default : throw new IllegalArgumentException ( "Invalid style character: " + ch ) ; } }
Gets the JDK style code from the Joda code .
32,659
public void setPeriod ( int years , int months , int weeks , int days , int hours , int minutes , int seconds , int millis ) { super . setPeriod ( years , months , weeks , days , hours , minutes , seconds , millis ) ; }
Sets all the fields in one go .
32,660
public void setPeriod ( ReadableInterval interval ) { if ( interval == null ) { setPeriod ( 0L ) ; } else { Chronology chrono = DateTimeUtils . getChronology ( interval . getChronology ( ) ) ; setPeriod ( interval . getStartMillis ( ) , interval . getEndMillis ( ) , chrono ) ; } }
Sets all the fields in one go from an interval using the ISO chronology and dividing the fields using the period type .
32,661
public void setPeriod ( long startInstant , long endInstant , Chronology chrono ) { chrono = DateTimeUtils . getChronology ( chrono ) ; setValues ( chrono . get ( this , startInstant , endInstant ) ) ; }
Sets all the fields in one go from a millisecond interval .
32,662
public void add ( int years , int months , int weeks , int days , int hours , int minutes , int seconds , int millis ) { setPeriod ( FieldUtils . safeAdd ( getYears ( ) , years ) , FieldUtils . safeAdd ( getMonths ( ) , months ) , FieldUtils . safeAdd ( getWeeks ( ) , weeks ) , FieldUtils . safeAdd ( getDays ( ) , days ) , FieldUtils . safeAdd ( getHours ( ) , hours ) , FieldUtils . safeAdd ( getMinutes ( ) , minutes ) , FieldUtils . safeAdd ( getSeconds ( ) , seconds ) , FieldUtils . safeAdd ( getMillis ( ) , millis ) ) ; }
Adds to each field of this period .
32,663
public Chronology getChronology ( Object object , DateTimeZone zone ) { return getChronology ( object , ( Chronology ) null ) . withZone ( zone ) ; }
Gets the chronology which is taken from the ReadablePartial .
32,664
public int [ ] getPartialValues ( ReadablePartial fieldSource , Object object , Chronology chrono ) { ReadablePartial input = ( ReadablePartial ) object ; int size = fieldSource . size ( ) ; int [ ] values = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { values [ i ] = input . get ( fieldSource . getFieldType ( i ) ) ; } chrono . validate ( fieldSource , values ) ; return values ; }
Extracts the values of the partial from an object of this converter s type . The chrono parameter is a hint to the converter should it require a chronology to aid in conversion .
32,665
public static BuddhistChronology getInstance ( DateTimeZone zone ) { if ( zone == null ) { zone = DateTimeZone . getDefault ( ) ; } BuddhistChronology chrono = cCache . get ( zone ) ; if ( chrono == null ) { chrono = new BuddhistChronology ( GJChronology . getInstance ( zone , null ) , null ) ; DateTime lowerLimit = new DateTime ( 1 , 1 , 1 , 0 , 0 , 0 , 0 , chrono ) ; chrono = new BuddhistChronology ( LimitChronology . getInstance ( chrono , lowerLimit , null ) , "" ) ; BuddhistChronology oldChrono = cCache . putIfAbsent ( zone , chrono ) ; if ( oldChrono != null ) { chrono = oldChrono ; } } return chrono ; }
Standard instance of a Buddhist Chronology that matches Sun s BuddhistCalendar class . This means that it follows the GregorianJulian calendar rules with a cutover date .
32,666
int getWeeksInYear ( int year ) { long firstWeekMillis1 = getFirstWeekOfYearMillis ( year ) ; long firstWeekMillis2 = getFirstWeekOfYearMillis ( year + 1 ) ; return ( int ) ( ( firstWeekMillis2 - firstWeekMillis1 ) / DateTimeConstants . MILLIS_PER_WEEK ) ; }
Get the number of weeks in the year .
32,667
long getFirstWeekOfYearMillis ( int year ) { long jan1millis = getYearMillis ( year ) ; int jan1dayOfWeek = getDayOfWeek ( jan1millis ) ; if ( jan1dayOfWeek > ( 8 - iMinDaysInFirstWeek ) ) { return jan1millis + ( 8 - jan1dayOfWeek ) * ( long ) DateTimeConstants . MILLIS_PER_DAY ; } else { return jan1millis - ( jan1dayOfWeek - 1 ) * ( long ) DateTimeConstants . MILLIS_PER_DAY ; } }
Get the millis for the first week of a year .
32,668
long getYearMonthMillis ( int year , int month ) { long millis = getYearMillis ( year ) ; millis += getTotalMillisByYearMonth ( year , month ) ; return millis ; }
Get the milliseconds for the start of a month .
32,669
long getYearMonthDayMillis ( int year , int month , int dayOfMonth ) { long millis = getYearMillis ( year ) ; millis += getTotalMillisByYearMonth ( year , month ) ; return millis + ( dayOfMonth - 1 ) * ( long ) DateTimeConstants . MILLIS_PER_DAY ; }
Get the milliseconds for a particular date .
32,670
int getDaysInMonthMax ( long instant ) { int thisYear = getYear ( instant ) ; int thisMonth = getMonthOfYear ( instant , thisYear ) ; return getDaysInYearMonth ( thisYear , thisMonth ) ; }
Gets the maximum number of days in the month specified by the instant .
32,671
long getDateMidnightMillis ( int year , int monthOfYear , int dayOfMonth ) { FieldUtils . verifyValueBounds ( DateTimeFieldType . year ( ) , year , getMinYear ( ) - 1 , getMaxYear ( ) + 1 ) ; FieldUtils . verifyValueBounds ( DateTimeFieldType . monthOfYear ( ) , monthOfYear , 1 , getMaxMonth ( year ) ) ; FieldUtils . verifyValueBounds ( DateTimeFieldType . dayOfMonth ( ) , dayOfMonth , 1 , getDaysInYearMonth ( year , monthOfYear ) ) ; long instant = getYearMonthDayMillis ( year , monthOfYear , dayOfMonth ) ; if ( instant < 0 && year == getMaxYear ( ) + 1 ) { return Long . MAX_VALUE ; } else if ( instant > 0 && year == getMinYear ( ) - 1 ) { return Long . MIN_VALUE ; } return instant ; }
Gets the milliseconds for a date at midnight .
32,672
private YearInfo getYearInfo ( int year ) { YearInfo info = iYearInfoCache [ year & CACHE_MASK ] ; if ( info == null || info . iYear != year ) { info = new YearInfo ( year , calculateFirstDayOfYearMillis ( year ) ) ; iYearInfoCache [ year & CACHE_MASK ] = info ; } return info ; }
Although accessed by multiple threads this method doesn t need to be synchronized .
32,673
public static CachedDateTimeZone forZone ( DateTimeZone zone ) { if ( zone instanceof CachedDateTimeZone ) { return ( CachedDateTimeZone ) zone ; } return new CachedDateTimeZone ( zone ) ; }
Returns a new CachedDateTimeZone unless given zone is already cached .
32,674
public java . util . TimeZone toTimeZone ( ) { String id = getID ( ) ; if ( id . length ( ) == 6 && ( id . startsWith ( "+" ) || id . startsWith ( "-" ) ) ) { return java . util . TimeZone . getTimeZone ( "GMT" + getID ( ) ) ; } return new java . util . SimpleTimeZone ( iWallOffset , getID ( ) ) ; }
Override to return the correct timezone instance .
32,675
public static DateTimeZone forOffsetMillis ( int millisOffset ) { if ( millisOffset < - MAX_MILLIS || millisOffset > MAX_MILLIS ) { throw new IllegalArgumentException ( "Millis out of range: " + millisOffset ) ; } String id = printOffset ( millisOffset ) ; return fixedOffsetZone ( id , millisOffset ) ; }
Gets a time zone instance for the specified offset to UTC in milliseconds .
32,676
private static DateTimeZone fixedOffsetZone ( String id , int offset ) { if ( offset == 0 ) { return DateTimeZone . UTC ; } return new FixedDateTimeZone ( id , null , offset , offset ) ; }
Gets the zone using a fixed offset amount .
32,677
private static Provider validateProvider ( Provider provider ) { Set < String > ids = provider . getAvailableIDs ( ) ; if ( ids == null || ids . size ( ) == 0 ) { throw new IllegalArgumentException ( "The provider doesn't have any available ids" ) ; } if ( ! ids . contains ( "UTC" ) ) { throw new IllegalArgumentException ( "The provider doesn't support UTC" ) ; } if ( ! UTC . equals ( provider . getZone ( "UTC" ) ) ) { throw new IllegalArgumentException ( "Invalid UTC zone provided" ) ; } return provider ; }
Sets the zone provider factory without performing the security check .
32,678
public final int getOffset ( ReadableInstant instant ) { if ( instant == null ) { return getOffset ( DateTimeUtils . currentTimeMillis ( ) ) ; } return getOffset ( instant . getMillis ( ) ) ; }
Gets the millisecond offset to add to UTC to get local time .
32,679
public int getOffsetFromLocal ( long instantLocal ) { final int offsetLocal = getOffset ( instantLocal ) ; final long instantAdjusted = instantLocal - offsetLocal ; final int offsetAdjusted = getOffset ( instantAdjusted ) ; if ( offsetLocal != offsetAdjusted ) { if ( ( offsetLocal - offsetAdjusted ) < 0 ) { long nextLocal = nextTransition ( instantAdjusted ) ; if ( nextLocal == ( instantLocal - offsetLocal ) ) { nextLocal = Long . MAX_VALUE ; } long nextAdjusted = nextTransition ( instantLocal - offsetAdjusted ) ; if ( nextAdjusted == ( instantLocal - offsetAdjusted ) ) { nextAdjusted = Long . MAX_VALUE ; } if ( nextLocal != nextAdjusted ) { return offsetLocal ; } } } else if ( offsetLocal >= 0 ) { long prev = previousTransition ( instantAdjusted ) ; if ( prev < instantAdjusted ) { int offsetPrev = getOffset ( prev ) ; int diff = offsetPrev - offsetLocal ; if ( instantAdjusted - prev <= diff ) { return offsetPrev ; } } } return offsetAdjusted ; }
Gets the millisecond offset to subtract from local time to get UTC time . This offset can be used to undo adding the offset obtained by getOffset .
32,680
public long convertUTCToLocal ( long instantUTC ) { int offset = getOffset ( instantUTC ) ; long instantLocal = instantUTC + offset ; if ( ( instantUTC ^ instantLocal ) < 0 && ( instantUTC ^ offset ) >= 0 ) { throw new ArithmeticException ( "Adding time zone offset caused overflow" ) ; } return instantLocal ; }
Converts a standard UTC instant to a local instant with the same local time . This conversion is used before performing a calculation so that the calculation can be done using a simple local zone .
32,681
public long convertLocalToUTC ( long instantLocal , boolean strict ) { int offsetLocal = getOffset ( instantLocal ) ; int offset = getOffset ( instantLocal - offsetLocal ) ; if ( offsetLocal != offset ) { if ( strict || offsetLocal < 0 ) { long nextLocal = nextTransition ( instantLocal - offsetLocal ) ; if ( nextLocal == ( instantLocal - offsetLocal ) ) { nextLocal = Long . MAX_VALUE ; } long nextAdjusted = nextTransition ( instantLocal - offset ) ; if ( nextAdjusted == ( instantLocal - offset ) ) { nextAdjusted = Long . MAX_VALUE ; } if ( nextLocal != nextAdjusted ) { if ( strict ) { throw new IllegalInstantException ( instantLocal , getID ( ) ) ; } else { offset = offsetLocal ; } } } } long instantUTC = instantLocal - offset ; if ( ( instantLocal ^ instantUTC ) < 0 && ( instantLocal ^ offset ) < 0 ) { throw new ArithmeticException ( "Subtracting time zone offset caused overflow" ) ; } return instantUTC ; }
Converts a local instant to a standard UTC instant with the same local time . This conversion is used after performing a calculation where the calculation was done using a simple local zone .
32,682
public long adjustOffset ( long instant , boolean earlierOrLater ) { long instantBefore = instant - 3 * DateTimeConstants . MILLIS_PER_HOUR ; long instantAfter = instant + 3 * DateTimeConstants . MILLIS_PER_HOUR ; long offsetBefore = getOffset ( instantBefore ) ; long offsetAfter = getOffset ( instantAfter ) ; if ( offsetBefore <= offsetAfter ) { return instant ; } long diff = offsetBefore - offsetAfter ; long transition = nextTransition ( instantBefore ) ; long overlapStart = transition - diff ; long overlapEnd = transition + diff ; if ( instant < overlapStart || instant >= overlapEnd ) { return instant ; } long afterStart = instant - overlapStart ; if ( afterStart >= diff ) { return earlierOrLater ? instant : instant - diff ; } else { return earlierOrLater ? instant + diff : instant ; } }
Adjusts the offset to be the earlier or later one during an overlap .
32,683
public int compare ( Object lhsObj , Object rhsObj ) { InstantConverter conv = ConverterManager . getInstance ( ) . getInstantConverter ( lhsObj ) ; Chronology lhsChrono = conv . getChronology ( lhsObj , ( Chronology ) null ) ; long lhsMillis = conv . getInstantMillis ( lhsObj , lhsChrono ) ; if ( lhsObj == rhsObj ) { return 0 ; } conv = ConverterManager . getInstance ( ) . getInstantConverter ( rhsObj ) ; Chronology rhsChrono = conv . getChronology ( rhsObj , ( Chronology ) null ) ; long rhsMillis = conv . getInstantMillis ( rhsObj , rhsChrono ) ; if ( iLowerLimit != null ) { lhsMillis = iLowerLimit . getField ( lhsChrono ) . roundFloor ( lhsMillis ) ; rhsMillis = iLowerLimit . getField ( rhsChrono ) . roundFloor ( rhsMillis ) ; } if ( iUpperLimit != null ) { lhsMillis = iUpperLimit . getField ( lhsChrono ) . remainder ( lhsMillis ) ; rhsMillis = iUpperLimit . getField ( rhsChrono ) . remainder ( rhsMillis ) ; } if ( lhsMillis < rhsMillis ) { return - 1 ; } else if ( lhsMillis > rhsMillis ) { return 1 ; } else { return 0 ; } }
Compare two objects against only the range of date time fields as specified in the constructor .
32,684
public DateMidnight toDateMidnight ( DateTimeZone zone ) { Chronology chrono = getChronology ( ) . withZone ( zone ) ; return new DateMidnight ( getYear ( ) , getMonthOfYear ( ) , getDayOfMonth ( ) , chrono ) ; }
Converts this object to a DateMidnight .
32,685
public Interval toInterval ( DateTimeZone zone ) { zone = DateTimeUtils . getZone ( zone ) ; return toDateMidnight ( zone ) . toInterval ( ) ; }
Converts this object to an Interval representing the whole day .
32,686
public int indexOf ( DateTimeFieldType type ) { for ( int i = 0 , isize = size ( ) ; i < isize ; i ++ ) { if ( getFieldType ( i ) == type ) { return i ; } } return - 1 ; }
Gets the index of the specified field or - 1 if the field is unsupported .
32,687
protected int indexOfSupported ( DateTimeFieldType type ) { int index = indexOf ( type ) ; if ( index == - 1 ) { throw new IllegalArgumentException ( "Field '" + type + "' is not supported" ) ; } return index ; }
Gets the index of the specified field throwing an exception if the field is unsupported .
32,688
protected int indexOf ( DurationFieldType type ) { for ( int i = 0 , isize = size ( ) ; i < isize ; i ++ ) { if ( getFieldType ( i ) . getDurationType ( ) == type ) { return i ; } } return - 1 ; }
Gets the index of the first fields to have the specified duration or - 1 if the field is unsupported .
32,689
protected int indexOfSupported ( DurationFieldType type ) { int index = indexOf ( type ) ; if ( index == - 1 ) { throw new IllegalArgumentException ( "Field '" + type + "' is not supported" ) ; } return index ; }
Gets the index of the first fields to have the specified duration throwing an exception if the field is unsupported .
32,690
public Chronology getChronology ( Object object , DateTimeZone zone ) { if ( object . getClass ( ) . getName ( ) . endsWith ( ".BuddhistCalendar" ) ) { return BuddhistChronology . getInstance ( zone ) ; } else if ( object instanceof GregorianCalendar ) { GregorianCalendar gc = ( GregorianCalendar ) object ; long cutover = gc . getGregorianChange ( ) . getTime ( ) ; if ( cutover == Long . MIN_VALUE ) { return GregorianChronology . getInstance ( zone ) ; } else if ( cutover == Long . MAX_VALUE ) { return JulianChronology . getInstance ( zone ) ; } else { return GJChronology . getInstance ( zone , cutover , 4 ) ; } } else { return ISOChronology . getInstance ( zone ) ; } }
Gets the chronology which is the GJChronology if a GregorianCalendar is used BuddhistChronology if a BuddhistCalendar is used or ISOChronology otherwise . The time zone specified is used in preference to that on the calendar .
32,691
public long getInstantMillis ( Object object , Chronology chrono ) { Calendar calendar = ( Calendar ) object ; return calendar . getTime ( ) . getTime ( ) ; }
Gets the millis which is the Calendar millis value .
32,692
public DateTimeFormatterBuilder appendDecimal ( DateTimeFieldType fieldType , int minDigits , int maxDigits ) { if ( fieldType == null ) { throw new IllegalArgumentException ( "Field type must not be null" ) ; } if ( maxDigits < minDigits ) { maxDigits = minDigits ; } if ( minDigits < 0 || maxDigits <= 0 ) { throw new IllegalArgumentException ( ) ; } if ( minDigits <= 1 ) { return append0 ( new UnpaddedNumber ( fieldType , maxDigits , false ) ) ; } else { return append0 ( new PaddedNumber ( fieldType , maxDigits , false , minDigits ) ) ; } }
Instructs the printer to emit a field value as a decimal number and the parser to expect an unsigned decimal number .
32,693
public DateTimeFormatterBuilder appendSignedDecimal ( DateTimeFieldType fieldType , int minDigits , int maxDigits ) { if ( fieldType == null ) { throw new IllegalArgumentException ( "Field type must not be null" ) ; } if ( maxDigits < minDigits ) { maxDigits = minDigits ; } if ( minDigits < 0 || maxDigits <= 0 ) { throw new IllegalArgumentException ( ) ; } if ( minDigits <= 1 ) { return append0 ( new UnpaddedNumber ( fieldType , maxDigits , true ) ) ; } else { return append0 ( new PaddedNumber ( fieldType , maxDigits , true , minDigits ) ) ; } }
Instructs the printer to emit a field value as a decimal number and the parser to expect a signed decimal number .
32,694
public DateTimeFormatterBuilder appendText ( DateTimeFieldType fieldType ) { if ( fieldType == null ) { throw new IllegalArgumentException ( "Field type must not be null" ) ; } return append0 ( new TextField ( fieldType , false ) ) ; }
Instructs the printer to emit a field value as text and the parser to expect text .
32,695
public DateTimeFormatterBuilder appendShortText ( DateTimeFieldType fieldType ) { if ( fieldType == null ) { throw new IllegalArgumentException ( "Field type must not be null" ) ; } return append0 ( new TextField ( fieldType , true ) ) ; }
Instructs the printer to emit a field value as short text and the parser to expect text .
32,696
public int [ ] get ( ReadablePartial partial , long instant ) { int size = partial . size ( ) ; int [ ] values = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { values [ i ] = partial . getFieldType ( i ) . getField ( this ) . get ( instant ) ; } return values ; }
Gets the values of a partial from an instant .
32,697
public long set ( ReadablePartial partial , long instant ) { for ( int i = 0 , isize = partial . size ( ) ; i < isize ; i ++ ) { instant = partial . getFieldType ( i ) . getField ( this ) . set ( instant , partial . getValue ( i ) ) ; } return instant ; }
Sets the partial into the instant .
32,698
public long add ( ReadablePeriod period , long instant , int scalar ) { if ( scalar != 0 && period != null ) { for ( int i = 0 , isize = period . size ( ) ; i < isize ; i ++ ) { long value = period . getValue ( i ) ; if ( value != 0 ) { instant = period . getFieldType ( i ) . getField ( this ) . add ( instant , value * scalar ) ; } } } return instant ; }
Adds the period to the instant specifying the number of times to add .
32,699
public long add ( long instant , long duration , int scalar ) { if ( duration == 0 || scalar == 0 ) { return instant ; } long add = FieldUtils . safeMultiply ( duration , scalar ) ; return FieldUtils . safeAdd ( instant , add ) ; }
Adds the duration to the instant specifying the number of times to add .