id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
22,300
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/FieldUtils.java
|
FieldUtils.safeSubtract
|
public static long safeSubtract(long val1, long val2) {
long diff = val1 - val2;
// If there is a sign change, but the two values have different signs...
if ((val1 ^ diff) < 0 && (val1 ^ val2) < 0) {
throw new ArithmeticException
("The calculation caused an overflow: " + val1 + " - " + val2);
}
return diff;
}
|
java
|
public static long safeSubtract(long val1, long val2) {
long diff = val1 - val2;
// If there is a sign change, but the two values have different signs...
if ((val1 ^ diff) < 0 && (val1 ^ val2) < 0) {
throw new ArithmeticException
("The calculation caused an overflow: " + val1 + " - " + val2);
}
return diff;
}
|
[
"public",
"static",
"long",
"safeSubtract",
"(",
"long",
"val1",
",",
"long",
"val2",
")",
"{",
"long",
"diff",
"=",
"val1",
"-",
"val2",
";",
"// If there is a sign change, but the two values have different signs...",
"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.
@param val1 the first value, to be taken away from
@param val2 the second value, the amount to take away
@return the new total
@throws ArithmeticException if the value is too big or too small
|
[
"Subtracts",
"two",
"values",
"throwing",
"an",
"exception",
"if",
"overflow",
"occurs",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/FieldUtils.java#L102-L110
|
22,301
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/FieldUtils.java
|
FieldUtils.safeDivide
|
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;
}
|
java
|
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;
}
|
[
"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.
@param dividend the dividend
@param divisor the divisor
@return the new total
@throws ArithmeticException if the operation overflows or the divisor is zero
|
[
"Divides",
"the",
"dividend",
"by",
"the",
"divisor",
"throwing",
"an",
"exception",
"if",
"overflow",
"occurs",
"or",
"the",
"divisor",
"is",
"zero",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/FieldUtils.java#L191-L196
|
22,302
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/FieldUtils.java
|
FieldUtils.safeDivide
|
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();
}
|
java
|
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();
}
|
[
"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.
@param dividend the dividend
@param divisor the divisor
@param roundingMode the desired rounding mode
@return the division result as per the specified rounding mode
@throws ArithmeticException if the operation overflows or the divisor is zero
|
[
"Divides",
"the",
"dividend",
"by",
"divisor",
".",
"Rounding",
"of",
"result",
"occurs",
"as",
"per",
"the",
"roundingMode",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/FieldUtils.java#L208-L216
|
22,303
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/FieldUtils.java
|
FieldUtils.safeMultiplyToInt
|
public static int safeMultiplyToInt(long val1, long val2) {
long val = FieldUtils.safeMultiply(val1, val2);
return FieldUtils.safeToInt(val);
}
|
java
|
public static int safeMultiplyToInt(long val1, long val2) {
long val = FieldUtils.safeMultiply(val1, val2);
return FieldUtils.safeToInt(val);
}
|
[
"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.
@param val1 the first value
@param val2 the second value
@return the new total
@throws ArithmeticException if the value is too big or too small
|
[
"Multiply",
"two",
"values",
"to",
"return",
"an",
"int",
"throwing",
"an",
"exception",
"if",
"overflow",
"occurs",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/FieldUtils.java#L240-L243
|
22,304
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/FieldUtils.java
|
FieldUtils.getWrappedValue
|
public static int getWrappedValue(int currentValue, int wrapValue,
int minValue, int maxValue) {
return getWrappedValue(currentValue + wrapValue, minValue, maxValue);
}
|
java
|
public static int getWrappedValue(int currentValue, int wrapValue,
int minValue, int maxValue) {
return getWrappedValue(currentValue + wrapValue, minValue, maxValue);
}
|
[
"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.
@param currentValue the current value of the data, which may lie outside
the wrapped value range
@param wrapValue the value to add to current value before
wrapping. This may be negative.
@param minValue the wrap range minimum value.
@param maxValue the wrap range maximum value. This must be
greater than minValue (checked by the method).
@return the wrapped value
@throws IllegalArgumentException if minValue is greater
than or equal to maxValue
|
[
"Utility",
"method",
"used",
"by",
"addWrapField",
"implementations",
"to",
"ensure",
"the",
"new",
"value",
"lies",
"within",
"the",
"field",
"s",
"legal",
"value",
"range",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/FieldUtils.java#L313-L316
|
22,305
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/FieldUtils.java
|
FieldUtils.getWrappedValue
|
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;
}
|
java
|
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;
}
|
[
"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.
@param value the value to fit into the wrapped value range
@param minValue the wrap range minimum value.
@param maxValue the wrap range maximum value. This must be
greater than minValue (checked by the method).
@return the wrapped value
@throws IllegalArgumentException if minValue is greater
than or equal to maxValue
|
[
"Utility",
"method",
"that",
"ensures",
"the",
"given",
"value",
"lies",
"within",
"the",
"field",
"s",
"legal",
"value",
"range",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/FieldUtils.java#L330-L348
|
22,306
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/format/DateTimeFormat.java
|
DateTimeFormat.isNumericToken
|
private static boolean isNumericToken(String token) {
int tokenLen = token.length();
if (tokenLen > 0) {
char c = token.charAt(0);
switch (c) {
case 'c': // century (number)
case 'C': // century of era (number)
case 'x': // weekyear (number)
case 'y': // year (number)
case 'Y': // year of era (number)
case 'd': // day of month (number)
case 'h': // hour of day (number, 1..12)
case 'H': // hour of day (number, 0..23)
case 'm': // minute of hour (number)
case 's': // second of minute (number)
case 'S': // fraction of second (number)
case 'e': // day of week (number)
case 'D': // day of year (number)
case 'F': // day of week in month (number)
case 'w': // week of year (number)
case 'W': // week of month (number)
case 'k': // hour of day (1..24)
case 'K': // hour of day (0..11)
return true;
case 'M': // month of year (text and number)
if (tokenLen <= 2) {
return true;
}
}
}
return false;
}
|
java
|
private static boolean isNumericToken(String token) {
int tokenLen = token.length();
if (tokenLen > 0) {
char c = token.charAt(0);
switch (c) {
case 'c': // century (number)
case 'C': // century of era (number)
case 'x': // weekyear (number)
case 'y': // year (number)
case 'Y': // year of era (number)
case 'd': // day of month (number)
case 'h': // hour of day (number, 1..12)
case 'H': // hour of day (number, 0..23)
case 'm': // minute of hour (number)
case 's': // second of minute (number)
case 'S': // fraction of second (number)
case 'e': // day of week (number)
case 'D': // day of year (number)
case 'F': // day of week in month (number)
case 'w': // week of year (number)
case 'W': // week of month (number)
case 'k': // hour of day (1..24)
case 'K': // hour of day (0..11)
return true;
case 'M': // month of year (text and number)
if (tokenLen <= 2) {
return true;
}
}
}
return false;
}
|
[
"private",
"static",
"boolean",
"isNumericToken",
"(",
"String",
"token",
")",
"{",
"int",
"tokenLen",
"=",
"token",
".",
"length",
"(",
")",
";",
"if",
"(",
"tokenLen",
">",
"0",
")",
"{",
"char",
"c",
"=",
"token",
".",
"charAt",
"(",
"0",
")",
";",
"switch",
"(",
"c",
")",
"{",
"case",
"'",
"'",
":",
"// century (number)",
"case",
"'",
"'",
":",
"// century of era (number)",
"case",
"'",
"'",
":",
"// weekyear (number)",
"case",
"'",
"'",
":",
"// year (number)",
"case",
"'",
"'",
":",
"// year of era (number)",
"case",
"'",
"'",
":",
"// day of month (number)",
"case",
"'",
"'",
":",
"// hour of day (number, 1..12)",
"case",
"'",
"'",
":",
"// hour of day (number, 0..23)",
"case",
"'",
"'",
":",
"// minute of hour (number)",
"case",
"'",
"'",
":",
"// second of minute (number)",
"case",
"'",
"'",
":",
"// fraction of second (number)",
"case",
"'",
"'",
":",
"// day of week (number)",
"case",
"'",
"'",
":",
"// day of year (number)",
"case",
"'",
"'",
":",
"// day of week in month (number)",
"case",
"'",
"'",
":",
"// week of year (number)",
"case",
"'",
"'",
":",
"// week of month (number)",
"case",
"'",
"'",
":",
"// hour of day (1..24)",
"case",
"'",
"'",
":",
"// hour of day (0..11)",
"return",
"true",
";",
"case",
"'",
"'",
":",
"// month of year (text and number)",
"if",
"(",
"tokenLen",
"<=",
"2",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns true if token should be parsed as a numeric field.
@param token the token to parse
@return true if numeric field
|
[
"Returns",
"true",
"if",
"token",
"should",
"be",
"parsed",
"as",
"a",
"numeric",
"field",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormat.java#L638-L670
|
22,307
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/format/DateTimeFormat.java
|
DateTimeFormat.createFormatterForPattern
|
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) {
// the size check is not locked against concurrent access,
// but is accepted to be slightly off in contention scenarios.
DateTimeFormatter oldFormatter = cPatternCache.putIfAbsent(pattern, formatter);
if (oldFormatter != null) {
formatter = oldFormatter;
}
}
}
return formatter;
}
|
java
|
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) {
// the size check is not locked against concurrent access,
// but is accepted to be slightly off in contention scenarios.
DateTimeFormatter oldFormatter = cPatternCache.putIfAbsent(pattern, formatter);
if (oldFormatter != null) {
formatter = oldFormatter;
}
}
}
return formatter;
}
|
[
"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",
")",
"{",
"// the size check is not locked against concurrent access,",
"// but is accepted to be slightly off in contention scenarios.",
"DateTimeFormatter",
"oldFormatter",
"=",
"cPatternCache",
".",
"putIfAbsent",
"(",
"pattern",
",",
"formatter",
")",
";",
"if",
"(",
"oldFormatter",
"!=",
"null",
")",
"{",
"formatter",
"=",
"oldFormatter",
";",
"}",
"}",
"}",
"return",
"formatter",
";",
"}"
] |
Select a format from a custom pattern.
@param pattern pattern specification
@throws IllegalArgumentException if the pattern is invalid
@see #appendPatternTo
|
[
"Select",
"a",
"format",
"from",
"a",
"custom",
"pattern",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormat.java#L680-L699
|
22,308
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/format/DateTimeFormat.java
|
DateTimeFormat.createFormatterForStyle
|
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);
}
|
java
|
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);
}
|
[
"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 '-'.
@param style two characters from the set {"S", "M", "L", "F", "-"}
@throws IllegalArgumentException if the style is invalid
|
[
"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",
"-",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormat.java#L710-L720
|
22,309
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/format/DateTimeFormat.java
|
DateTimeFormat.createFormatterForStyleIndex
|
private static DateTimeFormatter createFormatterForStyleIndex(int dateStyle, int timeStyle) {
int index = ((dateStyle << 2) + dateStyle) + timeStyle; // (dateStyle * 5 + timeStyle);
// Should never happen but do a double check...
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;
}
|
java
|
private static DateTimeFormatter createFormatterForStyleIndex(int dateStyle, int timeStyle) {
int index = ((dateStyle << 2) + dateStyle) + timeStyle; // (dateStyle * 5 + timeStyle);
// Should never happen but do a double check...
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;
}
|
[
"private",
"static",
"DateTimeFormatter",
"createFormatterForStyleIndex",
"(",
"int",
"dateStyle",
",",
"int",
"timeStyle",
")",
"{",
"int",
"index",
"=",
"(",
"(",
"dateStyle",
"<<",
"2",
")",
"+",
"dateStyle",
")",
"+",
"timeStyle",
";",
"// (dateStyle * 5 + timeStyle);",
"// Should never happen but do a double check...",
"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.
@param dateStyle the date style
@param timeStyle the time style
@return the formatter
|
[
"Gets",
"the",
"formatter",
"for",
"the",
"specified",
"style",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormat.java#L729-L743
|
22,310
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/format/DateTimeFormat.java
|
DateTimeFormat.createDateTimeFormatter
|
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);
}
|
java
|
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);
}
|
[
"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.
@param dateStyle the date style
@param timeStyle the time style
@return the formatter
|
[
"Creates",
"a",
"formatter",
"for",
"the",
"specified",
"style",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormat.java#L752-L761
|
22,311
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/format/DateTimeFormat.java
|
DateTimeFormat.selectStyle
|
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);
}
}
|
java
|
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);
}
}
|
[
"private",
"static",
"int",
"selectStyle",
"(",
"char",
"ch",
")",
"{",
"switch",
"(",
"ch",
")",
"{",
"case",
"'",
"'",
":",
"return",
"SHORT",
";",
"case",
"'",
"'",
":",
"return",
"MEDIUM",
";",
"case",
"'",
"'",
":",
"return",
"LONG",
";",
"case",
"'",
"'",
":",
"return",
"FULL",
";",
"case",
"'",
"'",
":",
"return",
"NONE",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid style character: \"",
"+",
"ch",
")",
";",
"}",
"}"
] |
Gets the JDK style code from the Joda code.
@param ch the Joda style code
@return the JDK style code
|
[
"Gets",
"the",
"JDK",
"style",
"code",
"from",
"the",
"Joda",
"code",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormat.java#L769-L784
|
22,312
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/MutablePeriod.java
|
MutablePeriod.setPeriod
|
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);
}
|
java
|
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);
}
|
[
"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.
@param years amount of years in this period, which must be zero if unsupported
@param months amount of months in this period, which must be zero if unsupported
@param weeks amount of weeks in this period, which must be zero if unsupported
@param days amount of days in this period, which must be zero if unsupported
@param hours amount of hours in this period, which must be zero if unsupported
@param minutes amount of minutes in this period, which must be zero if unsupported
@param seconds amount of seconds in this period, which must be zero if unsupported
@param millis amount of milliseconds in this period, which must be zero if unsupported
@throws IllegalArgumentException if an unsupported field's value is non-zero
|
[
"Sets",
"all",
"the",
"fields",
"in",
"one",
"go",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/MutablePeriod.java#L484-L487
|
22,313
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/MutablePeriod.java
|
MutablePeriod.setPeriod
|
public void setPeriod(ReadableInterval interval) {
if (interval == null) {
setPeriod(0L);
} else {
Chronology chrono = DateTimeUtils.getChronology(interval.getChronology());
setPeriod(interval.getStartMillis(), interval.getEndMillis(), chrono);
}
}
|
java
|
public void setPeriod(ReadableInterval interval) {
if (interval == null) {
setPeriod(0L);
} else {
Chronology chrono = DateTimeUtils.getChronology(interval.getChronology());
setPeriod(interval.getStartMillis(), interval.getEndMillis(), chrono);
}
}
|
[
"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.
@param interval the interval to set, null means zero length
@throws ArithmeticException if the set exceeds the capacity of the period
|
[
"Sets",
"all",
"the",
"fields",
"in",
"one",
"go",
"from",
"an",
"interval",
"using",
"the",
"ISO",
"chronology",
"and",
"dividing",
"the",
"fields",
"using",
"the",
"period",
"type",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/MutablePeriod.java#L496-L503
|
22,314
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/MutablePeriod.java
|
MutablePeriod.setPeriod
|
public void setPeriod(long startInstant, long endInstant, Chronology chrono) {
chrono = DateTimeUtils.getChronology(chrono);
setValues(chrono.get(this, startInstant, endInstant));
}
|
java
|
public void setPeriod(long startInstant, long endInstant, Chronology chrono) {
chrono = DateTimeUtils.getChronology(chrono);
setValues(chrono.get(this, startInstant, endInstant));
}
|
[
"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.
@param startInstant interval start, in milliseconds
@param endInstant interval end, in milliseconds
@param chrono the chronology to use, null means ISO chronology
@throws ArithmeticException if the set exceeds the capacity of the period
|
[
"Sets",
"all",
"the",
"fields",
"in",
"one",
"go",
"from",
"a",
"millisecond",
"interval",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/MutablePeriod.java#L546-L549
|
22,315
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/MutablePeriod.java
|
MutablePeriod.add
|
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)
);
}
|
java
|
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)
);
}
|
[
"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.
@param years amount of years to add to this period, which must be zero if unsupported
@param months amount of months to add to this period, which must be zero if unsupported
@param weeks amount of weeks to add to this period, which must be zero if unsupported
@param days amount of days to add to this period, which must be zero if unsupported
@param hours amount of hours to add to this period, which must be zero if unsupported
@param minutes amount of minutes to add to this period, which must be zero if unsupported
@param seconds amount of seconds to add to this period, which must be zero if unsupported
@param millis amount of milliseconds to add to this period, which must be zero if unsupported
@throws IllegalArgumentException if the period being added contains a field
not supported by this period
@throws ArithmeticException if the addition exceeds the capacity of the period
|
[
"Adds",
"to",
"each",
"field",
"of",
"this",
"period",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/MutablePeriod.java#L655-L667
|
22,316
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/convert/ReadablePartialConverter.java
|
ReadablePartialConverter.getChronology
|
public Chronology getChronology(Object object, DateTimeZone zone) {
return getChronology(object, (Chronology) null).withZone(zone);
}
|
java
|
public Chronology getChronology(Object object, DateTimeZone zone) {
return getChronology(object, (Chronology) null).withZone(zone);
}
|
[
"public",
"Chronology",
"getChronology",
"(",
"Object",
"object",
",",
"DateTimeZone",
"zone",
")",
"{",
"return",
"getChronology",
"(",
"object",
",",
"(",
"Chronology",
")",
"null",
")",
".",
"withZone",
"(",
"zone",
")",
";",
"}"
] |
Gets the chronology, which is taken from the ReadablePartial.
@param object the ReadablePartial to convert, must not be null
@param zone the specified zone to use, null means default zone
@return the chronology, never null
|
[
"Gets",
"the",
"chronology",
"which",
"is",
"taken",
"from",
"the",
"ReadablePartial",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/ReadablePartialConverter.java#L52-L54
|
22,317
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/convert/ReadablePartialConverter.java
|
ReadablePartialConverter.getPartialValues
|
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;
}
|
java
|
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;
}
|
[
"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.
@param fieldSource a partial that provides access to the fields.
This partial may be incomplete and only getFieldType(int) should be used
@param object the object to convert
@param chrono the chronology to use, which is the non-null result of getChronology()
@return the array of field values that match the fieldSource, must be non-null valid
@throws ClassCastException if the object is invalid
|
[
"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",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/ReadablePartialConverter.java#L86-L95
|
22,318
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BuddhistChronology.java
|
BuddhistChronology.getInstance
|
public static BuddhistChronology getInstance(DateTimeZone zone) {
if (zone == null) {
zone = DateTimeZone.getDefault();
}
BuddhistChronology chrono = cCache.get(zone);
if (chrono == null) {
// First create without a lower limit.
chrono = new BuddhistChronology(GJChronology.getInstance(zone, null), null);
// Impose lower limit and make another BuddhistChronology.
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;
}
|
java
|
public static BuddhistChronology getInstance(DateTimeZone zone) {
if (zone == null) {
zone = DateTimeZone.getDefault();
}
BuddhistChronology chrono = cCache.get(zone);
if (chrono == null) {
// First create without a lower limit.
chrono = new BuddhistChronology(GJChronology.getInstance(zone, null), null);
// Impose lower limit and make another BuddhistChronology.
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;
}
|
[
"public",
"static",
"BuddhistChronology",
"getInstance",
"(",
"DateTimeZone",
"zone",
")",
"{",
"if",
"(",
"zone",
"==",
"null",
")",
"{",
"zone",
"=",
"DateTimeZone",
".",
"getDefault",
"(",
")",
";",
"}",
"BuddhistChronology",
"chrono",
"=",
"cCache",
".",
"get",
"(",
"zone",
")",
";",
"if",
"(",
"chrono",
"==",
"null",
")",
"{",
"// First create without a lower limit.",
"chrono",
"=",
"new",
"BuddhistChronology",
"(",
"GJChronology",
".",
"getInstance",
"(",
"zone",
",",
"null",
")",
",",
"null",
")",
";",
"// Impose lower limit and make another BuddhistChronology.",
"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.
@param zone the time zone to use, null is default
|
[
"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",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BuddhistChronology.java#L104-L121
|
22,319
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BasicChronology.java
|
BasicChronology.getWeeksInYear
|
int getWeeksInYear(int year) {
long firstWeekMillis1 = getFirstWeekOfYearMillis(year);
long firstWeekMillis2 = getFirstWeekOfYearMillis(year + 1);
return (int) ((firstWeekMillis2 - firstWeekMillis1) / DateTimeConstants.MILLIS_PER_WEEK);
}
|
java
|
int getWeeksInYear(int year) {
long firstWeekMillis1 = getFirstWeekOfYearMillis(year);
long firstWeekMillis2 = getFirstWeekOfYearMillis(year + 1);
return (int) ((firstWeekMillis2 - firstWeekMillis1) / DateTimeConstants.MILLIS_PER_WEEK);
}
|
[
"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.
@param year the year to use
@return number of weeks in the year
|
[
"Get",
"the",
"number",
"of",
"weeks",
"in",
"the",
"year",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BasicChronology.java#L353-L357
|
22,320
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BasicChronology.java
|
BasicChronology.getFirstWeekOfYearMillis
|
long getFirstWeekOfYearMillis(int year) {
long jan1millis = getYearMillis(year);
int jan1dayOfWeek = getDayOfWeek(jan1millis);
if (jan1dayOfWeek > (8 - iMinDaysInFirstWeek)) {
// First week is end of previous year because it doesn't have enough days.
return jan1millis + (8 - jan1dayOfWeek)
* (long)DateTimeConstants.MILLIS_PER_DAY;
} else {
// First week is start of this year because it has enough days.
return jan1millis - (jan1dayOfWeek - 1)
* (long)DateTimeConstants.MILLIS_PER_DAY;
}
}
|
java
|
long getFirstWeekOfYearMillis(int year) {
long jan1millis = getYearMillis(year);
int jan1dayOfWeek = getDayOfWeek(jan1millis);
if (jan1dayOfWeek > (8 - iMinDaysInFirstWeek)) {
// First week is end of previous year because it doesn't have enough days.
return jan1millis + (8 - jan1dayOfWeek)
* (long)DateTimeConstants.MILLIS_PER_DAY;
} else {
// First week is start of this year because it has enough days.
return jan1millis - (jan1dayOfWeek - 1)
* (long)DateTimeConstants.MILLIS_PER_DAY;
}
}
|
[
"long",
"getFirstWeekOfYearMillis",
"(",
"int",
"year",
")",
"{",
"long",
"jan1millis",
"=",
"getYearMillis",
"(",
"year",
")",
";",
"int",
"jan1dayOfWeek",
"=",
"getDayOfWeek",
"(",
"jan1millis",
")",
";",
"if",
"(",
"jan1dayOfWeek",
">",
"(",
"8",
"-",
"iMinDaysInFirstWeek",
")",
")",
"{",
"// First week is end of previous year because it doesn't have enough days.",
"return",
"jan1millis",
"+",
"(",
"8",
"-",
"jan1dayOfWeek",
")",
"*",
"(",
"long",
")",
"DateTimeConstants",
".",
"MILLIS_PER_DAY",
";",
"}",
"else",
"{",
"// First week is start of this year because it has enough days.",
"return",
"jan1millis",
"-",
"(",
"jan1dayOfWeek",
"-",
"1",
")",
"*",
"(",
"long",
")",
"DateTimeConstants",
".",
"MILLIS_PER_DAY",
";",
"}",
"}"
] |
Get the millis for the first week of a year.
@param year the year to use
@return millis
|
[
"Get",
"the",
"millis",
"for",
"the",
"first",
"week",
"of",
"a",
"year",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BasicChronology.java#L365-L378
|
22,321
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BasicChronology.java
|
BasicChronology.getYearMonthMillis
|
long getYearMonthMillis(int year, int month) {
long millis = getYearMillis(year);
millis += getTotalMillisByYearMonth(year, month);
return millis;
}
|
java
|
long getYearMonthMillis(int year, int month) {
long millis = getYearMillis(year);
millis += getTotalMillisByYearMonth(year, month);
return millis;
}
|
[
"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.
@param year The year to use.
@param month The month to use
@return millis from 1970-01-01T00:00:00Z
|
[
"Get",
"the",
"milliseconds",
"for",
"the",
"start",
"of",
"a",
"month",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BasicChronology.java#L397-L401
|
22,322
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BasicChronology.java
|
BasicChronology.getYearMonthDayMillis
|
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;
}
|
java
|
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;
}
|
[
"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.
@param year The year to use.
@param month The month to use
@param dayOfMonth The day of the month to use
@return millis from 1970-01-01T00:00:00Z
|
[
"Get",
"the",
"milliseconds",
"for",
"a",
"particular",
"date",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BasicChronology.java#L411-L415
|
22,323
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BasicChronology.java
|
BasicChronology.getDaysInMonthMax
|
int getDaysInMonthMax(long instant) {
int thisYear = getYear(instant);
int thisMonth = getMonthOfYear(instant, thisYear);
return getDaysInYearMonth(thisYear, thisMonth);
}
|
java
|
int getDaysInMonthMax(long instant) {
int thisYear = getYear(instant);
int thisMonth = getMonthOfYear(instant, thisYear);
return getDaysInYearMonth(thisYear, thisMonth);
}
|
[
"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.
@param instant millis from 1970-01-01T00:00:00Z
@return the maximum number of days in the month
|
[
"Gets",
"the",
"maximum",
"number",
"of",
"days",
"in",
"the",
"month",
"specified",
"by",
"the",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BasicChronology.java#L601-L605
|
22,324
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BasicChronology.java
|
BasicChronology.getDateMidnightMillis
|
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);
// check for limit caused by min/max year +1/-1
if (instant < 0 && year == getMaxYear() + 1) {
return Long.MAX_VALUE;
} else if (instant > 0 && year == getMinYear() - 1) {
return Long.MIN_VALUE;
}
return instant;
}
|
java
|
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);
// check for limit caused by min/max year +1/-1
if (instant < 0 && year == getMaxYear() + 1) {
return Long.MAX_VALUE;
} else if (instant > 0 && year == getMinYear() - 1) {
return Long.MIN_VALUE;
}
return instant;
}
|
[
"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",
")",
";",
"// check for limit caused by min/max year +1/-1",
"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.
@param year the year
@param monthOfYear the month
@param dayOfMonth the day
@return the milliseconds
|
[
"Gets",
"the",
"milliseconds",
"for",
"a",
"date",
"at",
"midnight",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BasicChronology.java#L629-L641
|
22,325
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BasicChronology.java
|
BasicChronology.getYearInfo
|
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;
}
|
java
|
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;
}
|
[
"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.
|
[
"Although",
"accessed",
"by",
"multiple",
"threads",
"this",
"method",
"doesn",
"t",
"need",
"to",
"be",
"synchronized",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BasicChronology.java#L781-L788
|
22,326
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/tz/CachedDateTimeZone.java
|
CachedDateTimeZone.forZone
|
public static CachedDateTimeZone forZone(DateTimeZone zone) {
if (zone instanceof CachedDateTimeZone) {
return (CachedDateTimeZone)zone;
}
return new CachedDateTimeZone(zone);
}
|
java
|
public static CachedDateTimeZone forZone(DateTimeZone zone) {
if (zone instanceof CachedDateTimeZone) {
return (CachedDateTimeZone)zone;
}
return new CachedDateTimeZone(zone);
}
|
[
"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.
|
[
"Returns",
"a",
"new",
"CachedDateTimeZone",
"unless",
"given",
"zone",
"is",
"already",
"cached",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/tz/CachedDateTimeZone.java#L67-L72
|
22,327
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/tz/FixedDateTimeZone.java
|
FixedDateTimeZone.toTimeZone
|
public java.util.TimeZone toTimeZone() {
String id = getID();
if (id.length() == 6 && (id.startsWith("+") || id.startsWith("-"))) {
// standard format offset [+-]hh:mm
// our ID is without any prefix, so we need to add the GMT back
return java.util.TimeZone.getTimeZone("GMT" + getID());
}
// unusual offset, so setup a SimpleTimeZone as best we can
return new java.util.SimpleTimeZone(iWallOffset, getID());
}
|
java
|
public java.util.TimeZone toTimeZone() {
String id = getID();
if (id.length() == 6 && (id.startsWith("+") || id.startsWith("-"))) {
// standard format offset [+-]hh:mm
// our ID is without any prefix, so we need to add the GMT back
return java.util.TimeZone.getTimeZone("GMT" + getID());
}
// unusual offset, so setup a SimpleTimeZone as best we can
return new java.util.SimpleTimeZone(iWallOffset, getID());
}
|
[
"public",
"java",
".",
"util",
".",
"TimeZone",
"toTimeZone",
"(",
")",
"{",
"String",
"id",
"=",
"getID",
"(",
")",
";",
"if",
"(",
"id",
".",
"length",
"(",
")",
"==",
"6",
"&&",
"(",
"id",
".",
"startsWith",
"(",
"\"+\"",
")",
"||",
"id",
".",
"startsWith",
"(",
"\"-\"",
")",
")",
")",
"{",
"// standard format offset [+-]hh:mm",
"// our ID is without any prefix, so we need to add the GMT back",
"return",
"java",
".",
"util",
".",
"TimeZone",
".",
"getTimeZone",
"(",
"\"GMT\"",
"+",
"getID",
"(",
")",
")",
";",
"}",
"// unusual offset, so setup a SimpleTimeZone as best we can",
"return",
"new",
"java",
".",
"util",
".",
"SimpleTimeZone",
"(",
"iWallOffset",
",",
"getID",
"(",
")",
")",
";",
"}"
] |
Override to return the correct timezone instance.
@since 1.5
|
[
"Override",
"to",
"return",
"the",
"correct",
"timezone",
"instance",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/tz/FixedDateTimeZone.java#L76-L85
|
22,328
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/DateTimeZone.java
|
DateTimeZone.forOffsetMillis
|
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);
}
|
java
|
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);
}
|
[
"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.
@param millisOffset the offset in millis from UTC, from -23:59:59.999 to +23:59:59.999
@return the DateTimeZone object for the offset
|
[
"Gets",
"a",
"time",
"zone",
"instance",
"for",
"the",
"specified",
"offset",
"to",
"UTC",
"in",
"milliseconds",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/DateTimeZone.java#L316-L322
|
22,329
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/DateTimeZone.java
|
DateTimeZone.fixedOffsetZone
|
private static DateTimeZone fixedOffsetZone(String id, int offset) {
if (offset == 0) {
return DateTimeZone.UTC;
}
return new FixedDateTimeZone(id, null, offset, offset);
}
|
java
|
private static DateTimeZone fixedOffsetZone(String id, int offset) {
if (offset == 0) {
return DateTimeZone.UTC;
}
return new FixedDateTimeZone(id, null, offset, offset);
}
|
[
"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.
@param id the zone id
@param offset the offset in millis
@return the zone
|
[
"Gets",
"the",
"zone",
"using",
"a",
"fixed",
"offset",
"amount",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/DateTimeZone.java#L408-L413
|
22,330
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/DateTimeZone.java
|
DateTimeZone.validateProvider
|
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;
}
|
java
|
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;
}
|
[
"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.
@param provider provider to use, or null for default
@return the provider
@throws IllegalArgumentException if the provider is invalid
|
[
"Sets",
"the",
"zone",
"provider",
"factory",
"without",
"performing",
"the",
"security",
"check",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/DateTimeZone.java#L474-L486
|
22,331
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/DateTimeZone.java
|
DateTimeZone.getOffset
|
public final int getOffset(ReadableInstant instant) {
if (instant == null) {
return getOffset(DateTimeUtils.currentTimeMillis());
}
return getOffset(instant.getMillis());
}
|
java
|
public final int getOffset(ReadableInstant instant) {
if (instant == null) {
return getOffset(DateTimeUtils.currentTimeMillis());
}
return getOffset(instant.getMillis());
}
|
[
"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.
@param instant instant to get the offset for, null means now
@return the millisecond offset to add to UTC to get local time
|
[
"Gets",
"the",
"millisecond",
"offset",
"to",
"add",
"to",
"UTC",
"to",
"get",
"local",
"time",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/DateTimeZone.java#L837-L842
|
22,332
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/DateTimeZone.java
|
DateTimeZone.getOffsetFromLocal
|
public int getOffsetFromLocal(long instantLocal) {
// get the offset at instantLocal (first estimate)
final int offsetLocal = getOffset(instantLocal);
// adjust instantLocal using the estimate and recalc the offset
final long instantAdjusted = instantLocal - offsetLocal;
final int offsetAdjusted = getOffset(instantAdjusted);
// if the offsets differ, we must be near a DST boundary
if (offsetLocal != offsetAdjusted) {
// we need to ensure that time is always after the DST gap
// this happens naturally for positive offsets, but not for negative
if ((offsetLocal - offsetAdjusted) < 0) {
// if we just return offsetAdjusted then the time is pushed
// back before the transition, whereas it should be
// on or after the transition
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;
}
|
java
|
public int getOffsetFromLocal(long instantLocal) {
// get the offset at instantLocal (first estimate)
final int offsetLocal = getOffset(instantLocal);
// adjust instantLocal using the estimate and recalc the offset
final long instantAdjusted = instantLocal - offsetLocal;
final int offsetAdjusted = getOffset(instantAdjusted);
// if the offsets differ, we must be near a DST boundary
if (offsetLocal != offsetAdjusted) {
// we need to ensure that time is always after the DST gap
// this happens naturally for positive offsets, but not for negative
if ((offsetLocal - offsetAdjusted) < 0) {
// if we just return offsetAdjusted then the time is pushed
// back before the transition, whereas it should be
// on or after the transition
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;
}
|
[
"public",
"int",
"getOffsetFromLocal",
"(",
"long",
"instantLocal",
")",
"{",
"// get the offset at instantLocal (first estimate)",
"final",
"int",
"offsetLocal",
"=",
"getOffset",
"(",
"instantLocal",
")",
";",
"// adjust instantLocal using the estimate and recalc the offset",
"final",
"long",
"instantAdjusted",
"=",
"instantLocal",
"-",
"offsetLocal",
";",
"final",
"int",
"offsetAdjusted",
"=",
"getOffset",
"(",
"instantAdjusted",
")",
";",
"// if the offsets differ, we must be near a DST boundary",
"if",
"(",
"offsetLocal",
"!=",
"offsetAdjusted",
")",
"{",
"// we need to ensure that time is always after the DST gap",
"// this happens naturally for positive offsets, but not for negative",
"if",
"(",
"(",
"offsetLocal",
"-",
"offsetAdjusted",
")",
"<",
"0",
")",
"{",
"// if we just return offsetAdjusted then the time is pushed",
"// back before the transition, whereas it should be",
"// on or after the transition",
"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.
<pre>
millisLocal == millisUTC + getOffset(millisUTC)
millisUTC == millisLocal - getOffsetFromLocal(millisLocal)
</pre>
NOTE: After calculating millisLocal, some error may be introduced. At
offset transitions (due to DST or other historical changes), ranges of
local times may map to different UTC times.
<p>
For overlaps (where the local time is ambiguous), this method returns the
offset applicable before the gap. The effect of this is that any instant
calculated using the offset from an overlap will be in "summer" time.
<p>
For gaps, this method returns the offset applicable before the gap, ie "winter" offset.
However, the effect of this is that any instant calculated using the offset
from a gap will be after the gap, in "summer" time.
<p>
For example, consider a zone with a gap from 01:00 to 01:59:<br />
Input: 00:00 (before gap) Output: Offset applicable before gap DateTime: 00:00<br />
Input: 00:30 (before gap) Output: Offset applicable before gap DateTime: 00:30<br />
Input: 01:00 (in gap) Output: Offset applicable before gap DateTime: 02:00<br />
Input: 01:30 (in gap) Output: Offset applicable before gap DateTime: 02:30<br />
Input: 02:00 (after gap) Output: Offset applicable after gap DateTime: 02:00<br />
Input: 02:30 (after gap) Output: Offset applicable after gap DateTime: 02:30<br />
<p>
NOTE: Prior to v2.0, the DST overlap behaviour was not defined and varied by hemisphere.
Prior to v1.5, the DST gap behaviour was also not defined.
In v2.4, the documentation was clarified again.
@param instantLocal the millisecond instant, relative to this time zone, to get the offset for
@return the millisecond offset to subtract from local time to get UTC time
|
[
"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",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/DateTimeZone.java#L908-L945
|
22,333
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/DateTimeZone.java
|
DateTimeZone.convertUTCToLocal
|
public long convertUTCToLocal(long instantUTC) {
int offset = getOffset(instantUTC);
long instantLocal = instantUTC + offset;
// If there is a sign change, but the two values have the same sign...
if ((instantUTC ^ instantLocal) < 0 && (instantUTC ^ offset) >= 0) {
throw new ArithmeticException("Adding time zone offset caused overflow");
}
return instantLocal;
}
|
java
|
public long convertUTCToLocal(long instantUTC) {
int offset = getOffset(instantUTC);
long instantLocal = instantUTC + offset;
// If there is a sign change, but the two values have the same sign...
if ((instantUTC ^ instantLocal) < 0 && (instantUTC ^ offset) >= 0) {
throw new ArithmeticException("Adding time zone offset caused overflow");
}
return instantLocal;
}
|
[
"public",
"long",
"convertUTCToLocal",
"(",
"long",
"instantUTC",
")",
"{",
"int",
"offset",
"=",
"getOffset",
"(",
"instantUTC",
")",
";",
"long",
"instantLocal",
"=",
"instantUTC",
"+",
"offset",
";",
"// If there is a sign change, but the two values have the same sign...",
"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.
@param instantUTC the UTC instant to convert to local
@return the local instant with the same local time
@throws ArithmeticException if the result overflows a long
@since 1.5
|
[
"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",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/DateTimeZone.java#L957-L965
|
22,334
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/DateTimeZone.java
|
DateTimeZone.convertLocalToUTC
|
public long convertLocalToUTC(long instantLocal, boolean strict) {
// get the offset at instantLocal (first estimate)
int offsetLocal = getOffset(instantLocal);
// adjust instantLocal using the estimate and recalc the offset
int offset = getOffset(instantLocal - offsetLocal);
// if the offsets differ, we must be near a DST boundary
if (offsetLocal != offset) {
// if strict then always check if in DST gap
// otherwise only check if zone in Western hemisphere (as the
// value of offset is already correct for Eastern hemisphere)
if (strict || offsetLocal < 0) {
// determine if we are in the DST gap
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) {
// yes we are in the DST gap
if (strict) {
// DST gap is not acceptable
throw new IllegalInstantException(instantLocal, getID());
} else {
// DST gap is acceptable, but for the Western hemisphere
// the offset is wrong and will result in local times
// before the cutover so use the offsetLocal instead
offset = offsetLocal;
}
}
}
}
// check for overflow
long instantUTC = instantLocal - offset;
// If there is a sign change, but the two values have different signs...
if ((instantLocal ^ instantUTC) < 0 && (instantLocal ^ offset) < 0) {
throw new ArithmeticException("Subtracting time zone offset caused overflow");
}
return instantUTC;
}
|
java
|
public long convertLocalToUTC(long instantLocal, boolean strict) {
// get the offset at instantLocal (first estimate)
int offsetLocal = getOffset(instantLocal);
// adjust instantLocal using the estimate and recalc the offset
int offset = getOffset(instantLocal - offsetLocal);
// if the offsets differ, we must be near a DST boundary
if (offsetLocal != offset) {
// if strict then always check if in DST gap
// otherwise only check if zone in Western hemisphere (as the
// value of offset is already correct for Eastern hemisphere)
if (strict || offsetLocal < 0) {
// determine if we are in the DST gap
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) {
// yes we are in the DST gap
if (strict) {
// DST gap is not acceptable
throw new IllegalInstantException(instantLocal, getID());
} else {
// DST gap is acceptable, but for the Western hemisphere
// the offset is wrong and will result in local times
// before the cutover so use the offsetLocal instead
offset = offsetLocal;
}
}
}
}
// check for overflow
long instantUTC = instantLocal - offset;
// If there is a sign change, but the two values have different signs...
if ((instantLocal ^ instantUTC) < 0 && (instantLocal ^ offset) < 0) {
throw new ArithmeticException("Subtracting time zone offset caused overflow");
}
return instantUTC;
}
|
[
"public",
"long",
"convertLocalToUTC",
"(",
"long",
"instantLocal",
",",
"boolean",
"strict",
")",
"{",
"// get the offset at instantLocal (first estimate)",
"int",
"offsetLocal",
"=",
"getOffset",
"(",
"instantLocal",
")",
";",
"// adjust instantLocal using the estimate and recalc the offset",
"int",
"offset",
"=",
"getOffset",
"(",
"instantLocal",
"-",
"offsetLocal",
")",
";",
"// if the offsets differ, we must be near a DST boundary",
"if",
"(",
"offsetLocal",
"!=",
"offset",
")",
"{",
"// if strict then always check if in DST gap",
"// otherwise only check if zone in Western hemisphere (as the",
"// value of offset is already correct for Eastern hemisphere)",
"if",
"(",
"strict",
"||",
"offsetLocal",
"<",
"0",
")",
"{",
"// determine if we are in the DST gap",
"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",
")",
"{",
"// yes we are in the DST gap",
"if",
"(",
"strict",
")",
"{",
"// DST gap is not acceptable",
"throw",
"new",
"IllegalInstantException",
"(",
"instantLocal",
",",
"getID",
"(",
")",
")",
";",
"}",
"else",
"{",
"// DST gap is acceptable, but for the Western hemisphere",
"// the offset is wrong and will result in local times",
"// before the cutover so use the offsetLocal instead",
"offset",
"=",
"offsetLocal",
";",
"}",
"}",
"}",
"}",
"// check for overflow",
"long",
"instantUTC",
"=",
"instantLocal",
"-",
"offset",
";",
"// If there is a sign change, but the two values have different signs...",
"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.
@param instantLocal the local instant to convert to UTC
@param strict whether the conversion should reject non-existent local times
@return the UTC instant with the same local time,
@throws ArithmeticException if the result overflows a long
@throws IllegalInstantException if the zone has no equivalent local time
@since 1.5
|
[
"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",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/DateTimeZone.java#L1006-L1047
|
22,335
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/DateTimeZone.java
|
DateTimeZone.adjustOffset
|
public long adjustOffset(long instant, boolean earlierOrLater) {
// a bit messy, but will work in all non-pathological cases
// evaluate 3 hours before and after to work out if anything is happening
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; // not an overlap (less than is a gap, equal is normal case)
}
// work out range of instants that have duplicate local times
long diff = offsetBefore - offsetAfter;
long transition = nextTransition(instantBefore);
long overlapStart = transition - diff;
long overlapEnd = transition + diff;
if (instant < overlapStart || instant >= overlapEnd) {
return instant; // not an overlap
}
// calculate result
long afterStart = instant - overlapStart;
if (afterStart >= diff) {
// currently in later offset
return earlierOrLater ? instant : instant - diff;
} else {
// currently in earlier offset
return earlierOrLater ? instant + diff : instant;
}
}
|
java
|
public long adjustOffset(long instant, boolean earlierOrLater) {
// a bit messy, but will work in all non-pathological cases
// evaluate 3 hours before and after to work out if anything is happening
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; // not an overlap (less than is a gap, equal is normal case)
}
// work out range of instants that have duplicate local times
long diff = offsetBefore - offsetAfter;
long transition = nextTransition(instantBefore);
long overlapStart = transition - diff;
long overlapEnd = transition + diff;
if (instant < overlapStart || instant >= overlapEnd) {
return instant; // not an overlap
}
// calculate result
long afterStart = instant - overlapStart;
if (afterStart >= diff) {
// currently in later offset
return earlierOrLater ? instant : instant - diff;
} else {
// currently in earlier offset
return earlierOrLater ? instant + diff : instant;
}
}
|
[
"public",
"long",
"adjustOffset",
"(",
"long",
"instant",
",",
"boolean",
"earlierOrLater",
")",
"{",
"// a bit messy, but will work in all non-pathological cases",
"// evaluate 3 hours before and after to work out if anything is happening",
"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",
";",
"// not an overlap (less than is a gap, equal is normal case)",
"}",
"// work out range of instants that have duplicate local times",
"long",
"diff",
"=",
"offsetBefore",
"-",
"offsetAfter",
";",
"long",
"transition",
"=",
"nextTransition",
"(",
"instantBefore",
")",
";",
"long",
"overlapStart",
"=",
"transition",
"-",
"diff",
";",
"long",
"overlapEnd",
"=",
"transition",
"+",
"diff",
";",
"if",
"(",
"instant",
"<",
"overlapStart",
"||",
"instant",
">=",
"overlapEnd",
")",
"{",
"return",
"instant",
";",
"// not an overlap",
"}",
"// calculate result",
"long",
"afterStart",
"=",
"instant",
"-",
"overlapStart",
";",
"if",
"(",
"afterStart",
">=",
"diff",
")",
"{",
"// currently in later offset",
"return",
"earlierOrLater",
"?",
"instant",
":",
"instant",
"-",
"diff",
";",
"}",
"else",
"{",
"// currently in earlier offset",
"return",
"earlierOrLater",
"?",
"instant",
"+",
"diff",
":",
"instant",
";",
"}",
"}"
] |
Adjusts the offset to be the earlier or later one during an overlap.
@param instant the instant to adjust
@param earlierOrLater false for earlier, true for later
@return the adjusted instant millis
|
[
"Adjusts",
"the",
"offset",
"to",
"be",
"the",
"earlier",
"or",
"later",
"one",
"during",
"an",
"overlap",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/DateTimeZone.java#L1195-L1225
|
22,336
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/DateTimeComparator.java
|
DateTimeComparator.compare
|
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);
// handle null==null and other cases where objects are the same
// but only do this after checking the input is valid
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;
}
}
|
java
|
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);
// handle null==null and other cases where objects are the same
// but only do this after checking the input is valid
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;
}
}
|
[
"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",
")",
";",
"// handle null==null and other cases where objects are the same",
"// but only do this after checking the input is valid",
"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.
@param lhsObj the first object,
logically on the left of a < comparison, null means now
@param rhsObj the second object,
logically on the right of a < comparison, null means now
@return zero if order does not matter,
negative value if lhsObj < rhsObj, positive value otherwise.
@throws IllegalArgumentException if either argument is not supported
|
[
"Compare",
"two",
"objects",
"against",
"only",
"the",
"range",
"of",
"date",
"time",
"fields",
"as",
"specified",
"in",
"the",
"constructor",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/DateTimeComparator.java#L191-L223
|
22,337
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/YearMonthDay.java
|
YearMonthDay.toDateMidnight
|
public DateMidnight toDateMidnight(DateTimeZone zone) {
Chronology chrono = getChronology().withZone(zone);
return new DateMidnight(getYear(), getMonthOfYear(), getDayOfMonth(), chrono);
}
|
java
|
public DateMidnight toDateMidnight(DateTimeZone zone) {
Chronology chrono = getChronology().withZone(zone);
return new DateMidnight(getYear(), getMonthOfYear(), getDayOfMonth(), chrono);
}
|
[
"public",
"DateMidnight",
"toDateMidnight",
"(",
"DateTimeZone",
"zone",
")",
"{",
"Chronology",
"chrono",
"=",
"getChronology",
"(",
")",
".",
"withZone",
"(",
"zone",
")",
";",
"return",
"new",
"DateMidnight",
"(",
"getYear",
"(",
")",
",",
"getMonthOfYear",
"(",
")",
",",
"getDayOfMonth",
"(",
")",
",",
"chrono",
")",
";",
"}"
] |
Converts this object to a DateMidnight.
@param zone the zone to get the DateMidnight in, null means default
@return the DateMidnight instance
|
[
"Converts",
"this",
"object",
"to",
"a",
"DateMidnight",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/YearMonthDay.java#L734-L737
|
22,338
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/YearMonthDay.java
|
YearMonthDay.toInterval
|
public Interval toInterval(DateTimeZone zone) {
zone = DateTimeUtils.getZone(zone);
return toDateMidnight(zone).toInterval();
}
|
java
|
public Interval toInterval(DateTimeZone zone) {
zone = DateTimeUtils.getZone(zone);
return toDateMidnight(zone).toInterval();
}
|
[
"public",
"Interval",
"toInterval",
"(",
"DateTimeZone",
"zone",
")",
"{",
"zone",
"=",
"DateTimeUtils",
".",
"getZone",
"(",
"zone",
")",
";",
"return",
"toDateMidnight",
"(",
"zone",
")",
".",
"toInterval",
"(",
")",
";",
"}"
] |
Converts this object to an Interval representing the whole day.
@param zone the zone to get the Interval in, null means default
@return a interval over the day
|
[
"Converts",
"this",
"object",
"to",
"an",
"Interval",
"representing",
"the",
"whole",
"day",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/YearMonthDay.java#L796-L799
|
22,339
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/base/AbstractPartial.java
|
AbstractPartial.indexOf
|
public int indexOf(DateTimeFieldType type) {
for (int i = 0, isize = size(); i < isize; i++) {
if (getFieldType(i) == type) {
return i;
}
}
return -1;
}
|
java
|
public int indexOf(DateTimeFieldType type) {
for (int i = 0, isize = size(); i < isize; i++) {
if (getFieldType(i) == type) {
return i;
}
}
return -1;
}
|
[
"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.
@param type the type to check, may be null which returns -1
@return the index of the field, -1 if unsupported
|
[
"Gets",
"the",
"index",
"of",
"the",
"specified",
"field",
"or",
"-",
"1",
"if",
"the",
"field",
"is",
"unsupported",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/base/AbstractPartial.java#L169-L176
|
22,340
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/base/AbstractPartial.java
|
AbstractPartial.indexOfSupported
|
protected int indexOfSupported(DateTimeFieldType type) {
int index = indexOf(type);
if (index == -1) {
throw new IllegalArgumentException("Field '" + type + "' is not supported");
}
return index;
}
|
java
|
protected int indexOfSupported(DateTimeFieldType type) {
int index = indexOf(type);
if (index == -1) {
throw new IllegalArgumentException("Field '" + type + "' is not supported");
}
return index;
}
|
[
"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.
@param type the type to check, not null
@return the index of the field
@throws IllegalArgumentException if the field is null or not supported
|
[
"Gets",
"the",
"index",
"of",
"the",
"specified",
"field",
"throwing",
"an",
"exception",
"if",
"the",
"field",
"is",
"unsupported",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/base/AbstractPartial.java#L186-L192
|
22,341
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/base/AbstractPartial.java
|
AbstractPartial.indexOf
|
protected int indexOf(DurationFieldType type) {
for (int i = 0, isize = size(); i < isize; i++) {
if (getFieldType(i).getDurationType() == type) {
return i;
}
}
return -1;
}
|
java
|
protected int indexOf(DurationFieldType type) {
for (int i = 0, isize = size(); i < isize; i++) {
if (getFieldType(i).getDurationType() == type) {
return i;
}
}
return -1;
}
|
[
"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.
@param type the type to check, may be null which returns -1
@return the index of the field, -1 if unsupported
|
[
"Gets",
"the",
"index",
"of",
"the",
"first",
"fields",
"to",
"have",
"the",
"specified",
"duration",
"or",
"-",
"1",
"if",
"the",
"field",
"is",
"unsupported",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/base/AbstractPartial.java#L201-L208
|
22,342
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/base/AbstractPartial.java
|
AbstractPartial.indexOfSupported
|
protected int indexOfSupported(DurationFieldType type) {
int index = indexOf(type);
if (index == -1) {
throw new IllegalArgumentException("Field '" + type + "' is not supported");
}
return index;
}
|
java
|
protected int indexOfSupported(DurationFieldType type) {
int index = indexOf(type);
if (index == -1) {
throw new IllegalArgumentException("Field '" + type + "' is not supported");
}
return index;
}
|
[
"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.
@param type the type to check, not null
@return the index of the field
@throws IllegalArgumentException if the field is null or not supported
|
[
"Gets",
"the",
"index",
"of",
"the",
"first",
"fields",
"to",
"have",
"the",
"specified",
"duration",
"throwing",
"an",
"exception",
"if",
"the",
"field",
"is",
"unsupported",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/base/AbstractPartial.java#L218-L224
|
22,343
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/convert/CalendarConverter.java
|
CalendarConverter.getChronology
|
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);
}
}
|
java
|
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);
}
}
|
[
"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.
@param object the Calendar to convert, must not be null
@param zone the specified zone to use, null means default zone
@return the chronology, never null
@throws NullPointerException if the object is null
@throws ClassCastException if the object is an invalid type
|
[
"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",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/CalendarConverter.java#L93-L109
|
22,344
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/convert/CalendarConverter.java
|
CalendarConverter.getInstantMillis
|
public long getInstantMillis(Object object, Chronology chrono) {
Calendar calendar = (Calendar) object;
return calendar.getTime().getTime();
}
|
java
|
public long getInstantMillis(Object object, Chronology chrono) {
Calendar calendar = (Calendar) object;
return calendar.getTime().getTime();
}
|
[
"public",
"long",
"getInstantMillis",
"(",
"Object",
"object",
",",
"Chronology",
"chrono",
")",
"{",
"Calendar",
"calendar",
"=",
"(",
"Calendar",
")",
"object",
";",
"return",
"calendar",
".",
"getTime",
"(",
")",
".",
"getTime",
"(",
")",
";",
"}"
] |
Gets the millis, which is the Calendar millis value.
@param object the Calendar to convert, must not be null
@param chrono the chronology result from getChronology, non-null
@return the millisecond value
@throws NullPointerException if the object is null
@throws ClassCastException if the object is an invalid type
|
[
"Gets",
"the",
"millis",
"which",
"is",
"the",
"Calendar",
"millis",
"value",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/CalendarConverter.java#L120-L123
|
22,345
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java
|
DateTimeFormatterBuilder.appendDecimal
|
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));
}
}
|
java
|
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));
}
}
|
[
"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.
@param fieldType type of field to append
@param minDigits minimum number of digits to <i>print</i>
@param maxDigits maximum number of digits to <i>parse</i>, or the estimated
maximum number of digits to print
@return this DateTimeFormatterBuilder, for chaining
@throws IllegalArgumentException if field type is null
|
[
"Instructs",
"the",
"printer",
"to",
"emit",
"a",
"field",
"value",
"as",
"a",
"decimal",
"number",
"and",
"the",
"parser",
"to",
"expect",
"an",
"unsigned",
"decimal",
"number",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java#L433-L449
|
22,346
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java
|
DateTimeFormatterBuilder.appendSignedDecimal
|
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));
}
}
|
java
|
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));
}
}
|
[
"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.
@param fieldType type of field to append
@param minDigits minimum number of digits to <i>print</i>
@param maxDigits maximum number of digits to <i>parse</i>, or the estimated
maximum number of digits to print
@return this DateTimeFormatterBuilder, for chaining
@throws IllegalArgumentException if field type is null
|
[
"Instructs",
"the",
"printer",
"to",
"emit",
"a",
"field",
"value",
"as",
"a",
"decimal",
"number",
"and",
"the",
"parser",
"to",
"expect",
"a",
"signed",
"decimal",
"number",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java#L485-L501
|
22,347
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java
|
DateTimeFormatterBuilder.appendText
|
public DateTimeFormatterBuilder appendText(DateTimeFieldType fieldType) {
if (fieldType == null) {
throw new IllegalArgumentException("Field type must not be null");
}
return append0(new TextField(fieldType, false));
}
|
java
|
public DateTimeFormatterBuilder appendText(DateTimeFieldType fieldType) {
if (fieldType == null) {
throw new IllegalArgumentException("Field type must not be null");
}
return append0(new TextField(fieldType, false));
}
|
[
"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.
@param fieldType type of field to append
@return this DateTimeFormatterBuilder, for chaining
@throws IllegalArgumentException if field type is null
|
[
"Instructs",
"the",
"printer",
"to",
"emit",
"a",
"field",
"value",
"as",
"text",
"and",
"the",
"parser",
"to",
"expect",
"text",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java#L534-L539
|
22,348
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java
|
DateTimeFormatterBuilder.appendShortText
|
public DateTimeFormatterBuilder appendShortText(DateTimeFieldType fieldType) {
if (fieldType == null) {
throw new IllegalArgumentException("Field type must not be null");
}
return append0(new TextField(fieldType, true));
}
|
java
|
public DateTimeFormatterBuilder appendShortText(DateTimeFieldType fieldType) {
if (fieldType == null) {
throw new IllegalArgumentException("Field type must not be null");
}
return append0(new TextField(fieldType, true));
}
|
[
"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.
@param fieldType type of field to append
@return this DateTimeFormatterBuilder, for chaining
@throws IllegalArgumentException if field type is null
|
[
"Instructs",
"the",
"printer",
"to",
"emit",
"a",
"field",
"value",
"as",
"short",
"text",
"and",
"the",
"parser",
"to",
"expect",
"text",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java#L549-L554
|
22,349
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BaseChronology.java
|
BaseChronology.get
|
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;
}
|
java
|
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;
}
|
[
"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.
@param partial the partial instant to use
@param instant the instant to query
@return the values of the partial extracted from the instant
|
[
"Gets",
"the",
"values",
"of",
"a",
"partial",
"from",
"an",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BaseChronology.java#L222-L229
|
22,350
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BaseChronology.java
|
BaseChronology.set
|
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;
}
|
java
|
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;
}
|
[
"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.
@param partial the partial instant to use
@param instant the instant to update
@return the updated instant
|
[
"Sets",
"the",
"partial",
"into",
"the",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BaseChronology.java#L238-L243
|
22,351
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BaseChronology.java
|
BaseChronology.add
|
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); // use long to allow for multiplication (fits OK)
if (value != 0) {
instant = period.getFieldType(i).getField(this).add(instant, value * scalar);
}
}
}
return instant;
}
|
java
|
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); // use long to allow for multiplication (fits OK)
if (value != 0) {
instant = period.getFieldType(i).getField(this).add(instant, value * scalar);
}
}
}
return instant;
}
|
[
"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",
")",
";",
"// use long to allow for multiplication (fits OK)",
"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.
@param period the period to add, null means add nothing
@param instant the instant to add to
@param scalar the number of times to add
@return the updated instant
|
[
"Adds",
"the",
"period",
"to",
"the",
"instant",
"specifying",
"the",
"number",
"of",
"times",
"to",
"add",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BaseChronology.java#L302-L312
|
22,352
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BaseChronology.java
|
BaseChronology.add
|
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);
}
|
java
|
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);
}
|
[
"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.
@param instant the instant to add to
@param duration the duration to add
@param scalar the number of times to add
@return the updated instant
|
[
"Adds",
"the",
"duration",
"to",
"the",
"instant",
"specifying",
"the",
"number",
"of",
"times",
"to",
"add",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BaseChronology.java#L323-L329
|
22,353
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BasicWeekyearDateTimeField.java
|
BasicWeekyearDateTimeField.add
|
public long add(long instant, int years) {
if (years == 0) {
return instant;
}
return set(instant, get(instant) + years);
}
|
java
|
public long add(long instant, int years) {
if (years == 0) {
return instant;
}
return set(instant, get(instant) + years);
}
|
[
"public",
"long",
"add",
"(",
"long",
"instant",
",",
"int",
"years",
")",
"{",
"if",
"(",
"years",
"==",
"0",
")",
"{",
"return",
"instant",
";",
"}",
"return",
"set",
"(",
"instant",
",",
"get",
"(",
"instant",
")",
"+",
"years",
")",
";",
"}"
] |
Add the specified years to the specified time instant.
@see org.joda.time.DateTimeField#add
@param instant the time instant in millis to update.
@param years the years to add (can be negative).
@return the updated time instant.
|
[
"Add",
"the",
"specified",
"years",
"to",
"the",
"specified",
"time",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BasicWeekyearDateTimeField.java#L72-L77
|
22,354
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BasicWeekyearDateTimeField.java
|
BasicWeekyearDateTimeField.set
|
public long set(long instant, int year) {
FieldUtils.verifyValueBounds(this, Math.abs(year),
iChronology.getMinYear(), iChronology.getMaxYear());
//
// Do nothing if no real change is requested.
//
int thisWeekyear = get( instant );
if ( thisWeekyear == year ) {
return instant;
}
//
// Calculate the DayOfWeek (to be preserved).
//
int thisDow = iChronology.getDayOfWeek(instant);
//
// Calculate the maximum weeks in the target year.
//
int weeksInFromYear = iChronology.getWeeksInYear( thisWeekyear );
int weeksInToYear = iChronology.getWeeksInYear( year );
int maxOutWeeks = (weeksInToYear < weeksInFromYear) ?
weeksInToYear : weeksInFromYear;
//
// Get the current week of the year. This will be preserved in
// the output unless it is greater than the maximum possible
// for the target weekyear. In that case it is adjusted
// to the maximum possible.
//
int setToWeek = iChronology.getWeekOfWeekyear(instant);
if ( setToWeek > maxOutWeeks ) {
setToWeek = maxOutWeeks;
}
//
// Get a wroking copy of the current date-time.
// This can be a convenience for debugging.
//
long workInstant = instant; // Get a copy
//
// Attempt to get close to the proper weekyear.
// Note - we cannot currently call ourself, so we just call
// set for the year. This at least gets us close.
//
workInstant = iChronology.setYear( workInstant, year );
//
// Calculate the weekyear number for the get close to value
// (which might not be equal to the year just set).
//
int workWoyYear = get( workInstant );
//
// At most we are off by one year, which can be "fixed" by
// adding/subtracting a week.
//
if ( workWoyYear < year ) {
workInstant += DateTimeConstants.MILLIS_PER_WEEK;
} else if ( workWoyYear > year ) {
workInstant -= DateTimeConstants.MILLIS_PER_WEEK;
}
//
// Set the proper week in the current weekyear.
//
// BEGIN: possible set WeekOfWeekyear logic.
int currentWoyWeek = iChronology.getWeekOfWeekyear(workInstant);
// No range check required (we already know it is OK).
workInstant = workInstant + (setToWeek - currentWoyWeek)
* (long)DateTimeConstants.MILLIS_PER_WEEK;
// END: possible set WeekOfWeekyear logic.
//
// Reset DayOfWeek to previous value.
//
// Note: This works fine, but it ideally shouldn't invoke other
// fields from within a field.
workInstant = iChronology.dayOfWeek().set( workInstant, thisDow );
//
// Return result.
//
return workInstant;
}
|
java
|
public long set(long instant, int year) {
FieldUtils.verifyValueBounds(this, Math.abs(year),
iChronology.getMinYear(), iChronology.getMaxYear());
//
// Do nothing if no real change is requested.
//
int thisWeekyear = get( instant );
if ( thisWeekyear == year ) {
return instant;
}
//
// Calculate the DayOfWeek (to be preserved).
//
int thisDow = iChronology.getDayOfWeek(instant);
//
// Calculate the maximum weeks in the target year.
//
int weeksInFromYear = iChronology.getWeeksInYear( thisWeekyear );
int weeksInToYear = iChronology.getWeeksInYear( year );
int maxOutWeeks = (weeksInToYear < weeksInFromYear) ?
weeksInToYear : weeksInFromYear;
//
// Get the current week of the year. This will be preserved in
// the output unless it is greater than the maximum possible
// for the target weekyear. In that case it is adjusted
// to the maximum possible.
//
int setToWeek = iChronology.getWeekOfWeekyear(instant);
if ( setToWeek > maxOutWeeks ) {
setToWeek = maxOutWeeks;
}
//
// Get a wroking copy of the current date-time.
// This can be a convenience for debugging.
//
long workInstant = instant; // Get a copy
//
// Attempt to get close to the proper weekyear.
// Note - we cannot currently call ourself, so we just call
// set for the year. This at least gets us close.
//
workInstant = iChronology.setYear( workInstant, year );
//
// Calculate the weekyear number for the get close to value
// (which might not be equal to the year just set).
//
int workWoyYear = get( workInstant );
//
// At most we are off by one year, which can be "fixed" by
// adding/subtracting a week.
//
if ( workWoyYear < year ) {
workInstant += DateTimeConstants.MILLIS_PER_WEEK;
} else if ( workWoyYear > year ) {
workInstant -= DateTimeConstants.MILLIS_PER_WEEK;
}
//
// Set the proper week in the current weekyear.
//
// BEGIN: possible set WeekOfWeekyear logic.
int currentWoyWeek = iChronology.getWeekOfWeekyear(workInstant);
// No range check required (we already know it is OK).
workInstant = workInstant + (setToWeek - currentWoyWeek)
* (long)DateTimeConstants.MILLIS_PER_WEEK;
// END: possible set WeekOfWeekyear logic.
//
// Reset DayOfWeek to previous value.
//
// Note: This works fine, but it ideally shouldn't invoke other
// fields from within a field.
workInstant = iChronology.dayOfWeek().set( workInstant, thisDow );
//
// Return result.
//
return workInstant;
}
|
[
"public",
"long",
"set",
"(",
"long",
"instant",
",",
"int",
"year",
")",
"{",
"FieldUtils",
".",
"verifyValueBounds",
"(",
"this",
",",
"Math",
".",
"abs",
"(",
"year",
")",
",",
"iChronology",
".",
"getMinYear",
"(",
")",
",",
"iChronology",
".",
"getMaxYear",
"(",
")",
")",
";",
"//",
"// Do nothing if no real change is requested.",
"//",
"int",
"thisWeekyear",
"=",
"get",
"(",
"instant",
")",
";",
"if",
"(",
"thisWeekyear",
"==",
"year",
")",
"{",
"return",
"instant",
";",
"}",
"//",
"// Calculate the DayOfWeek (to be preserved).",
"//",
"int",
"thisDow",
"=",
"iChronology",
".",
"getDayOfWeek",
"(",
"instant",
")",
";",
"//",
"// Calculate the maximum weeks in the target year.",
"//",
"int",
"weeksInFromYear",
"=",
"iChronology",
".",
"getWeeksInYear",
"(",
"thisWeekyear",
")",
";",
"int",
"weeksInToYear",
"=",
"iChronology",
".",
"getWeeksInYear",
"(",
"year",
")",
";",
"int",
"maxOutWeeks",
"=",
"(",
"weeksInToYear",
"<",
"weeksInFromYear",
")",
"?",
"weeksInToYear",
":",
"weeksInFromYear",
";",
"//",
"// Get the current week of the year. This will be preserved in",
"// the output unless it is greater than the maximum possible",
"// for the target weekyear. In that case it is adjusted",
"// to the maximum possible.",
"//",
"int",
"setToWeek",
"=",
"iChronology",
".",
"getWeekOfWeekyear",
"(",
"instant",
")",
";",
"if",
"(",
"setToWeek",
">",
"maxOutWeeks",
")",
"{",
"setToWeek",
"=",
"maxOutWeeks",
";",
"}",
"//",
"// Get a wroking copy of the current date-time.",
"// This can be a convenience for debugging.",
"//",
"long",
"workInstant",
"=",
"instant",
";",
"// Get a copy",
"//",
"// Attempt to get close to the proper weekyear.",
"// Note - we cannot currently call ourself, so we just call",
"// set for the year. This at least gets us close.",
"//",
"workInstant",
"=",
"iChronology",
".",
"setYear",
"(",
"workInstant",
",",
"year",
")",
";",
"//",
"// Calculate the weekyear number for the get close to value",
"// (which might not be equal to the year just set).",
"//",
"int",
"workWoyYear",
"=",
"get",
"(",
"workInstant",
")",
";",
"//",
"// At most we are off by one year, which can be \"fixed\" by",
"// adding/subtracting a week.",
"//",
"if",
"(",
"workWoyYear",
"<",
"year",
")",
"{",
"workInstant",
"+=",
"DateTimeConstants",
".",
"MILLIS_PER_WEEK",
";",
"}",
"else",
"if",
"(",
"workWoyYear",
">",
"year",
")",
"{",
"workInstant",
"-=",
"DateTimeConstants",
".",
"MILLIS_PER_WEEK",
";",
"}",
"//",
"// Set the proper week in the current weekyear.",
"//",
"// BEGIN: possible set WeekOfWeekyear logic.",
"int",
"currentWoyWeek",
"=",
"iChronology",
".",
"getWeekOfWeekyear",
"(",
"workInstant",
")",
";",
"// No range check required (we already know it is OK).",
"workInstant",
"=",
"workInstant",
"+",
"(",
"setToWeek",
"-",
"currentWoyWeek",
")",
"*",
"(",
"long",
")",
"DateTimeConstants",
".",
"MILLIS_PER_WEEK",
";",
"// END: possible set WeekOfWeekyear logic.",
"//",
"// Reset DayOfWeek to previous value.",
"//",
"// Note: This works fine, but it ideally shouldn't invoke other",
"// fields from within a field.",
"workInstant",
"=",
"iChronology",
".",
"dayOfWeek",
"(",
")",
".",
"set",
"(",
"workInstant",
",",
"thisDow",
")",
";",
"//",
"// Return result.",
"//",
"return",
"workInstant",
";",
"}"
] |
Set the Year of a week based year component of the specified time instant.
@see org.joda.time.DateTimeField#set
@param instant the time instant in millis to update.
@param year the year (-9999,9999) to set the date to.
@return the updated DateTime.
@throws IllegalArgumentException if year is invalid.
|
[
"Set",
"the",
"Year",
"of",
"a",
"week",
"based",
"year",
"component",
"of",
"the",
"specified",
"time",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BasicWeekyearDateTimeField.java#L128-L206
|
22,355
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/convert/ReadableIntervalConverter.java
|
ReadableIntervalConverter.setInto
|
public void setInto(ReadWritablePeriod writablePeriod, Object object, Chronology chrono) {
ReadableInterval interval = (ReadableInterval) object;
chrono = (chrono != null ? chrono : DateTimeUtils.getIntervalChronology(interval));
long start = interval.getStartMillis();
long end = interval.getEndMillis();
int[] values = chrono.get(writablePeriod, start, end);
for (int i = 0; i < values.length; i++) {
writablePeriod.setValue(i, values[i]);
}
}
|
java
|
public void setInto(ReadWritablePeriod writablePeriod, Object object, Chronology chrono) {
ReadableInterval interval = (ReadableInterval) object;
chrono = (chrono != null ? chrono : DateTimeUtils.getIntervalChronology(interval));
long start = interval.getStartMillis();
long end = interval.getEndMillis();
int[] values = chrono.get(writablePeriod, start, end);
for (int i = 0; i < values.length; i++) {
writablePeriod.setValue(i, values[i]);
}
}
|
[
"public",
"void",
"setInto",
"(",
"ReadWritablePeriod",
"writablePeriod",
",",
"Object",
"object",
",",
"Chronology",
"chrono",
")",
"{",
"ReadableInterval",
"interval",
"=",
"(",
"ReadableInterval",
")",
"object",
";",
"chrono",
"=",
"(",
"chrono",
"!=",
"null",
"?",
"chrono",
":",
"DateTimeUtils",
".",
"getIntervalChronology",
"(",
"interval",
")",
")",
";",
"long",
"start",
"=",
"interval",
".",
"getStartMillis",
"(",
")",
";",
"long",
"end",
"=",
"interval",
".",
"getEndMillis",
"(",
")",
";",
"int",
"[",
"]",
"values",
"=",
"chrono",
".",
"get",
"(",
"writablePeriod",
",",
"start",
",",
"end",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"length",
";",
"i",
"++",
")",
"{",
"writablePeriod",
".",
"setValue",
"(",
"i",
",",
"values",
"[",
"i",
"]",
")",
";",
"}",
"}"
] |
Sets the values of the mutable duration from the specified interval.
@param writablePeriod the period to modify
@param object the interval to set from
@param chrono the chronology to use
|
[
"Sets",
"the",
"values",
"of",
"the",
"mutable",
"duration",
"from",
"the",
"specified",
"interval",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/ReadableIntervalConverter.java#L63-L72
|
22,356
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/convert/StringConverter.java
|
StringConverter.getInstantMillis
|
public long getInstantMillis(Object object, Chronology chrono) {
String str = (String) object;
DateTimeFormatter p = ISODateTimeFormat.dateTimeParser();
return p.withChronology(chrono).parseMillis(str);
}
|
java
|
public long getInstantMillis(Object object, Chronology chrono) {
String str = (String) object;
DateTimeFormatter p = ISODateTimeFormat.dateTimeParser();
return p.withChronology(chrono).parseMillis(str);
}
|
[
"public",
"long",
"getInstantMillis",
"(",
"Object",
"object",
",",
"Chronology",
"chrono",
")",
"{",
"String",
"str",
"=",
"(",
"String",
")",
"object",
";",
"DateTimeFormatter",
"p",
"=",
"ISODateTimeFormat",
".",
"dateTimeParser",
"(",
")",
";",
"return",
"p",
".",
"withChronology",
"(",
"chrono",
")",
".",
"parseMillis",
"(",
"str",
")",
";",
"}"
] |
Gets the millis, which is the ISO parsed string value.
@param object the String to convert, must not be null
@param chrono the chronology to use, non-null result of getChronology
@return the millisecond value
@throws IllegalArgumentException if the value if invalid
|
[
"Gets",
"the",
"millis",
"which",
"is",
"the",
"ISO",
"parsed",
"string",
"value",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/StringConverter.java#L62-L66
|
22,357
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/convert/StringConverter.java
|
StringConverter.getPartialValues
|
public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) {
if (parser.getZone() != null) {
chrono = chrono.withZone(parser.getZone());
}
long millis = parser.withChronology(chrono).parseMillis((String) object);
return chrono.get(fieldSource, millis);
}
|
java
|
public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) {
if (parser.getZone() != null) {
chrono = chrono.withZone(parser.getZone());
}
long millis = parser.withChronology(chrono).parseMillis((String) object);
return chrono.get(fieldSource, millis);
}
|
[
"public",
"int",
"[",
"]",
"getPartialValues",
"(",
"ReadablePartial",
"fieldSource",
",",
"Object",
"object",
",",
"Chronology",
"chrono",
",",
"DateTimeFormatter",
"parser",
")",
"{",
"if",
"(",
"parser",
".",
"getZone",
"(",
")",
"!=",
"null",
")",
"{",
"chrono",
"=",
"chrono",
".",
"withZone",
"(",
"parser",
".",
"getZone",
"(",
")",
")",
";",
"}",
"long",
"millis",
"=",
"parser",
".",
"withChronology",
"(",
"chrono",
")",
".",
"parseMillis",
"(",
"(",
"String",
")",
"object",
")",
";",
"return",
"chrono",
".",
"get",
"(",
"fieldSource",
",",
"millis",
")",
";",
"}"
] |
Extracts the values of the partial from an object of this converter's type.
This method checks if the parser has a zone, and uses it if present.
This is most useful for parsing local times with UTC.
@param fieldSource a partial that provides access to the fields.
This partial may be incomplete and only getFieldType(int) should be used
@param object the object to convert
@param chrono the chronology to use, which is the non-null result of getChronology()
@param parser the parser to use, may be null
@return the array of field values that match the fieldSource, must be non-null valid
@throws ClassCastException if the object is invalid
@throws IllegalArgumentException if the value if invalid
@since 1.3
|
[
"Extracts",
"the",
"values",
"of",
"the",
"partial",
"from",
"an",
"object",
"of",
"this",
"converter",
"s",
"type",
".",
"This",
"method",
"checks",
"if",
"the",
"parser",
"has",
"a",
"zone",
"and",
"uses",
"it",
"if",
"present",
".",
"This",
"is",
"most",
"useful",
"for",
"parsing",
"local",
"times",
"with",
"UTC",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/StringConverter.java#L83-L89
|
22,358
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/convert/StringConverter.java
|
StringConverter.setInto
|
public void setInto(ReadWritableInterval writableInterval, Object object, Chronology chrono) {
String str = (String) object;
int separator = str.indexOf('/');
if (separator < 0) {
throw new IllegalArgumentException("Format requires a '/' separator: " + str);
}
String leftStr = str.substring(0, separator);
if (leftStr.length() <= 0) {
throw new IllegalArgumentException("Format invalid: " + str);
}
String rightStr = str.substring(separator + 1);
if (rightStr.length() <= 0) {
throw new IllegalArgumentException("Format invalid: " + str);
}
DateTimeFormatter dateTimeParser = ISODateTimeFormat.dateTimeParser();
dateTimeParser = dateTimeParser.withChronology(chrono);
PeriodFormatter periodParser = ISOPeriodFormat.standard();
long startInstant = 0, endInstant = 0;
Period period = null;
Chronology parsedChrono = null;
// before slash
char c = leftStr.charAt(0);
if (c == 'P' || c == 'p') {
period = periodParser.withParseType(getPeriodType(leftStr)).parsePeriod(leftStr);
} else {
DateTime start = dateTimeParser.parseDateTime(leftStr);
startInstant = start.getMillis();
parsedChrono = start.getChronology();
}
// after slash
c = rightStr.charAt(0);
if (c == 'P' || c == 'p') {
if (period != null) {
throw new IllegalArgumentException("Interval composed of two durations: " + str);
}
period = periodParser.withParseType(getPeriodType(rightStr)).parsePeriod(rightStr);
chrono = (chrono != null ? chrono : parsedChrono);
endInstant = chrono.add(period, startInstant, 1);
} else {
DateTime end = dateTimeParser.parseDateTime(rightStr);
endInstant = end.getMillis();
parsedChrono = (parsedChrono != null ? parsedChrono : end.getChronology());
chrono = (chrono != null ? chrono : parsedChrono);
if (period != null) {
startInstant = chrono.add(period, endInstant, -1);
}
}
writableInterval.setInterval(startInstant, endInstant);
writableInterval.setChronology(chrono);
}
|
java
|
public void setInto(ReadWritableInterval writableInterval, Object object, Chronology chrono) {
String str = (String) object;
int separator = str.indexOf('/');
if (separator < 0) {
throw new IllegalArgumentException("Format requires a '/' separator: " + str);
}
String leftStr = str.substring(0, separator);
if (leftStr.length() <= 0) {
throw new IllegalArgumentException("Format invalid: " + str);
}
String rightStr = str.substring(separator + 1);
if (rightStr.length() <= 0) {
throw new IllegalArgumentException("Format invalid: " + str);
}
DateTimeFormatter dateTimeParser = ISODateTimeFormat.dateTimeParser();
dateTimeParser = dateTimeParser.withChronology(chrono);
PeriodFormatter periodParser = ISOPeriodFormat.standard();
long startInstant = 0, endInstant = 0;
Period period = null;
Chronology parsedChrono = null;
// before slash
char c = leftStr.charAt(0);
if (c == 'P' || c == 'p') {
period = periodParser.withParseType(getPeriodType(leftStr)).parsePeriod(leftStr);
} else {
DateTime start = dateTimeParser.parseDateTime(leftStr);
startInstant = start.getMillis();
parsedChrono = start.getChronology();
}
// after slash
c = rightStr.charAt(0);
if (c == 'P' || c == 'p') {
if (period != null) {
throw new IllegalArgumentException("Interval composed of two durations: " + str);
}
period = periodParser.withParseType(getPeriodType(rightStr)).parsePeriod(rightStr);
chrono = (chrono != null ? chrono : parsedChrono);
endInstant = chrono.add(period, startInstant, 1);
} else {
DateTime end = dateTimeParser.parseDateTime(rightStr);
endInstant = end.getMillis();
parsedChrono = (parsedChrono != null ? parsedChrono : end.getChronology());
chrono = (chrono != null ? chrono : parsedChrono);
if (period != null) {
startInstant = chrono.add(period, endInstant, -1);
}
}
writableInterval.setInterval(startInstant, endInstant);
writableInterval.setChronology(chrono);
}
|
[
"public",
"void",
"setInto",
"(",
"ReadWritableInterval",
"writableInterval",
",",
"Object",
"object",
",",
"Chronology",
"chrono",
")",
"{",
"String",
"str",
"=",
"(",
"String",
")",
"object",
";",
"int",
"separator",
"=",
"str",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"separator",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Format requires a '/' separator: \"",
"+",
"str",
")",
";",
"}",
"String",
"leftStr",
"=",
"str",
".",
"substring",
"(",
"0",
",",
"separator",
")",
";",
"if",
"(",
"leftStr",
".",
"length",
"(",
")",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Format invalid: \"",
"+",
"str",
")",
";",
"}",
"String",
"rightStr",
"=",
"str",
".",
"substring",
"(",
"separator",
"+",
"1",
")",
";",
"if",
"(",
"rightStr",
".",
"length",
"(",
")",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Format invalid: \"",
"+",
"str",
")",
";",
"}",
"DateTimeFormatter",
"dateTimeParser",
"=",
"ISODateTimeFormat",
".",
"dateTimeParser",
"(",
")",
";",
"dateTimeParser",
"=",
"dateTimeParser",
".",
"withChronology",
"(",
"chrono",
")",
";",
"PeriodFormatter",
"periodParser",
"=",
"ISOPeriodFormat",
".",
"standard",
"(",
")",
";",
"long",
"startInstant",
"=",
"0",
",",
"endInstant",
"=",
"0",
";",
"Period",
"period",
"=",
"null",
";",
"Chronology",
"parsedChrono",
"=",
"null",
";",
"// before slash",
"char",
"c",
"=",
"leftStr",
".",
"charAt",
"(",
"0",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
")",
"{",
"period",
"=",
"periodParser",
".",
"withParseType",
"(",
"getPeriodType",
"(",
"leftStr",
")",
")",
".",
"parsePeriod",
"(",
"leftStr",
")",
";",
"}",
"else",
"{",
"DateTime",
"start",
"=",
"dateTimeParser",
".",
"parseDateTime",
"(",
"leftStr",
")",
";",
"startInstant",
"=",
"start",
".",
"getMillis",
"(",
")",
";",
"parsedChrono",
"=",
"start",
".",
"getChronology",
"(",
")",
";",
"}",
"// after slash",
"c",
"=",
"rightStr",
".",
"charAt",
"(",
"0",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
")",
"{",
"if",
"(",
"period",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Interval composed of two durations: \"",
"+",
"str",
")",
";",
"}",
"period",
"=",
"periodParser",
".",
"withParseType",
"(",
"getPeriodType",
"(",
"rightStr",
")",
")",
".",
"parsePeriod",
"(",
"rightStr",
")",
";",
"chrono",
"=",
"(",
"chrono",
"!=",
"null",
"?",
"chrono",
":",
"parsedChrono",
")",
";",
"endInstant",
"=",
"chrono",
".",
"add",
"(",
"period",
",",
"startInstant",
",",
"1",
")",
";",
"}",
"else",
"{",
"DateTime",
"end",
"=",
"dateTimeParser",
".",
"parseDateTime",
"(",
"rightStr",
")",
";",
"endInstant",
"=",
"end",
".",
"getMillis",
"(",
")",
";",
"parsedChrono",
"=",
"(",
"parsedChrono",
"!=",
"null",
"?",
"parsedChrono",
":",
"end",
".",
"getChronology",
"(",
")",
")",
";",
"chrono",
"=",
"(",
"chrono",
"!=",
"null",
"?",
"chrono",
":",
"parsedChrono",
")",
";",
"if",
"(",
"period",
"!=",
"null",
")",
"{",
"startInstant",
"=",
"chrono",
".",
"add",
"(",
"period",
",",
"endInstant",
",",
"-",
"1",
")",
";",
"}",
"}",
"writableInterval",
".",
"setInterval",
"(",
"startInstant",
",",
"endInstant",
")",
";",
"writableInterval",
".",
"setChronology",
"(",
"chrono",
")",
";",
"}"
] |
Sets the value of the mutable interval from the string.
@param writableInterval the interval to set
@param object the String to convert, must not be null
@param chrono the chronology to use, may be null
|
[
"Sets",
"the",
"value",
"of",
"the",
"mutable",
"interval",
"from",
"the",
"string",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/StringConverter.java#L183-L238
|
22,359
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/PeriodType.java
|
PeriodType.years
|
public static PeriodType years() {
PeriodType type = cYears;
if (type == null) {
type = new PeriodType(
"Years",
new DurationFieldType[] { DurationFieldType.years() },
new int[] { 0, -1, -1, -1, -1, -1, -1, -1, }
);
cYears = type;
}
return type;
}
|
java
|
public static PeriodType years() {
PeriodType type = cYears;
if (type == null) {
type = new PeriodType(
"Years",
new DurationFieldType[] { DurationFieldType.years() },
new int[] { 0, -1, -1, -1, -1, -1, -1, -1, }
);
cYears = type;
}
return type;
}
|
[
"public",
"static",
"PeriodType",
"years",
"(",
")",
"{",
"PeriodType",
"type",
"=",
"cYears",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"type",
"=",
"new",
"PeriodType",
"(",
"\"Years\"",
",",
"new",
"DurationFieldType",
"[",
"]",
"{",
"DurationFieldType",
".",
"years",
"(",
")",
"}",
",",
"new",
"int",
"[",
"]",
"{",
"0",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"}",
")",
";",
"cYears",
"=",
"type",
";",
"}",
"return",
"type",
";",
"}"
] |
Gets a type that defines just the years field.
@return the period type
|
[
"Gets",
"a",
"type",
"that",
"defines",
"just",
"the",
"years",
"field",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/PeriodType.java#L353-L364
|
22,360
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/PeriodType.java
|
PeriodType.months
|
public static PeriodType months() {
PeriodType type = cMonths;
if (type == null) {
type = new PeriodType(
"Months",
new DurationFieldType[] { DurationFieldType.months() },
new int[] { -1, 0, -1, -1, -1, -1, -1, -1, }
);
cMonths = type;
}
return type;
}
|
java
|
public static PeriodType months() {
PeriodType type = cMonths;
if (type == null) {
type = new PeriodType(
"Months",
new DurationFieldType[] { DurationFieldType.months() },
new int[] { -1, 0, -1, -1, -1, -1, -1, -1, }
);
cMonths = type;
}
return type;
}
|
[
"public",
"static",
"PeriodType",
"months",
"(",
")",
"{",
"PeriodType",
"type",
"=",
"cMonths",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"type",
"=",
"new",
"PeriodType",
"(",
"\"Months\"",
",",
"new",
"DurationFieldType",
"[",
"]",
"{",
"DurationFieldType",
".",
"months",
"(",
")",
"}",
",",
"new",
"int",
"[",
"]",
"{",
"-",
"1",
",",
"0",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"}",
")",
";",
"cMonths",
"=",
"type",
";",
"}",
"return",
"type",
";",
"}"
] |
Gets a type that defines just the months field.
@return the period type
|
[
"Gets",
"a",
"type",
"that",
"defines",
"just",
"the",
"months",
"field",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/PeriodType.java#L371-L382
|
22,361
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/PeriodType.java
|
PeriodType.weeks
|
public static PeriodType weeks() {
PeriodType type = cWeeks;
if (type == null) {
type = new PeriodType(
"Weeks",
new DurationFieldType[] { DurationFieldType.weeks() },
new int[] { -1, -1, 0, -1, -1, -1, -1, -1, }
);
cWeeks = type;
}
return type;
}
|
java
|
public static PeriodType weeks() {
PeriodType type = cWeeks;
if (type == null) {
type = new PeriodType(
"Weeks",
new DurationFieldType[] { DurationFieldType.weeks() },
new int[] { -1, -1, 0, -1, -1, -1, -1, -1, }
);
cWeeks = type;
}
return type;
}
|
[
"public",
"static",
"PeriodType",
"weeks",
"(",
")",
"{",
"PeriodType",
"type",
"=",
"cWeeks",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"type",
"=",
"new",
"PeriodType",
"(",
"\"Weeks\"",
",",
"new",
"DurationFieldType",
"[",
"]",
"{",
"DurationFieldType",
".",
"weeks",
"(",
")",
"}",
",",
"new",
"int",
"[",
"]",
"{",
"-",
"1",
",",
"-",
"1",
",",
"0",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"}",
")",
";",
"cWeeks",
"=",
"type",
";",
"}",
"return",
"type",
";",
"}"
] |
Gets a type that defines just the weeks field.
@return the period type
|
[
"Gets",
"a",
"type",
"that",
"defines",
"just",
"the",
"weeks",
"field",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/PeriodType.java#L389-L400
|
22,362
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/PeriodType.java
|
PeriodType.days
|
public static PeriodType days() {
PeriodType type = cDays;
if (type == null) {
type = new PeriodType(
"Days",
new DurationFieldType[] { DurationFieldType.days() },
new int[] { -1, -1, -1, 0, -1, -1, -1, -1, }
);
cDays = type;
}
return type;
}
|
java
|
public static PeriodType days() {
PeriodType type = cDays;
if (type == null) {
type = new PeriodType(
"Days",
new DurationFieldType[] { DurationFieldType.days() },
new int[] { -1, -1, -1, 0, -1, -1, -1, -1, }
);
cDays = type;
}
return type;
}
|
[
"public",
"static",
"PeriodType",
"days",
"(",
")",
"{",
"PeriodType",
"type",
"=",
"cDays",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"type",
"=",
"new",
"PeriodType",
"(",
"\"Days\"",
",",
"new",
"DurationFieldType",
"[",
"]",
"{",
"DurationFieldType",
".",
"days",
"(",
")",
"}",
",",
"new",
"int",
"[",
"]",
"{",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"0",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"}",
")",
";",
"cDays",
"=",
"type",
";",
"}",
"return",
"type",
";",
"}"
] |
Gets a type that defines just the days field.
@return the period type
|
[
"Gets",
"a",
"type",
"that",
"defines",
"just",
"the",
"days",
"field",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/PeriodType.java#L407-L418
|
22,363
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/PeriodType.java
|
PeriodType.hours
|
public static PeriodType hours() {
PeriodType type = cHours;
if (type == null) {
type = new PeriodType(
"Hours",
new DurationFieldType[] { DurationFieldType.hours() },
new int[] { -1, -1, -1, -1, 0, -1, -1, -1, }
);
cHours = type;
}
return type;
}
|
java
|
public static PeriodType hours() {
PeriodType type = cHours;
if (type == null) {
type = new PeriodType(
"Hours",
new DurationFieldType[] { DurationFieldType.hours() },
new int[] { -1, -1, -1, -1, 0, -1, -1, -1, }
);
cHours = type;
}
return type;
}
|
[
"public",
"static",
"PeriodType",
"hours",
"(",
")",
"{",
"PeriodType",
"type",
"=",
"cHours",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"type",
"=",
"new",
"PeriodType",
"(",
"\"Hours\"",
",",
"new",
"DurationFieldType",
"[",
"]",
"{",
"DurationFieldType",
".",
"hours",
"(",
")",
"}",
",",
"new",
"int",
"[",
"]",
"{",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"0",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"}",
")",
";",
"cHours",
"=",
"type",
";",
"}",
"return",
"type",
";",
"}"
] |
Gets a type that defines just the hours field.
@return the period type
|
[
"Gets",
"a",
"type",
"that",
"defines",
"just",
"the",
"hours",
"field",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/PeriodType.java#L425-L436
|
22,364
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/PeriodType.java
|
PeriodType.minutes
|
public static PeriodType minutes() {
PeriodType type = cMinutes;
if (type == null) {
type = new PeriodType(
"Minutes",
new DurationFieldType[] { DurationFieldType.minutes() },
new int[] { -1, -1, -1, -1, -1, 0, -1, -1, }
);
cMinutes = type;
}
return type;
}
|
java
|
public static PeriodType minutes() {
PeriodType type = cMinutes;
if (type == null) {
type = new PeriodType(
"Minutes",
new DurationFieldType[] { DurationFieldType.minutes() },
new int[] { -1, -1, -1, -1, -1, 0, -1, -1, }
);
cMinutes = type;
}
return type;
}
|
[
"public",
"static",
"PeriodType",
"minutes",
"(",
")",
"{",
"PeriodType",
"type",
"=",
"cMinutes",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"type",
"=",
"new",
"PeriodType",
"(",
"\"Minutes\"",
",",
"new",
"DurationFieldType",
"[",
"]",
"{",
"DurationFieldType",
".",
"minutes",
"(",
")",
"}",
",",
"new",
"int",
"[",
"]",
"{",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"0",
",",
"-",
"1",
",",
"-",
"1",
",",
"}",
")",
";",
"cMinutes",
"=",
"type",
";",
"}",
"return",
"type",
";",
"}"
] |
Gets a type that defines just the minutes field.
@return the period type
|
[
"Gets",
"a",
"type",
"that",
"defines",
"just",
"the",
"minutes",
"field",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/PeriodType.java#L443-L454
|
22,365
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/PeriodType.java
|
PeriodType.seconds
|
public static PeriodType seconds() {
PeriodType type = cSeconds;
if (type == null) {
type = new PeriodType(
"Seconds",
new DurationFieldType[] { DurationFieldType.seconds() },
new int[] { -1, -1, -1, -1, -1, -1, 0, -1, }
);
cSeconds = type;
}
return type;
}
|
java
|
public static PeriodType seconds() {
PeriodType type = cSeconds;
if (type == null) {
type = new PeriodType(
"Seconds",
new DurationFieldType[] { DurationFieldType.seconds() },
new int[] { -1, -1, -1, -1, -1, -1, 0, -1, }
);
cSeconds = type;
}
return type;
}
|
[
"public",
"static",
"PeriodType",
"seconds",
"(",
")",
"{",
"PeriodType",
"type",
"=",
"cSeconds",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"type",
"=",
"new",
"PeriodType",
"(",
"\"Seconds\"",
",",
"new",
"DurationFieldType",
"[",
"]",
"{",
"DurationFieldType",
".",
"seconds",
"(",
")",
"}",
",",
"new",
"int",
"[",
"]",
"{",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"0",
",",
"-",
"1",
",",
"}",
")",
";",
"cSeconds",
"=",
"type",
";",
"}",
"return",
"type",
";",
"}"
] |
Gets a type that defines just the seconds field.
@return the period type
|
[
"Gets",
"a",
"type",
"that",
"defines",
"just",
"the",
"seconds",
"field",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/PeriodType.java#L461-L472
|
22,366
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/PeriodType.java
|
PeriodType.millis
|
public static PeriodType millis() {
PeriodType type = cMillis;
if (type == null) {
type = new PeriodType(
"Millis",
new DurationFieldType[] { DurationFieldType.millis() },
new int[] { -1, -1, -1, -1, -1, -1, -1, 0, }
);
cMillis = type;
}
return type;
}
|
java
|
public static PeriodType millis() {
PeriodType type = cMillis;
if (type == null) {
type = new PeriodType(
"Millis",
new DurationFieldType[] { DurationFieldType.millis() },
new int[] { -1, -1, -1, -1, -1, -1, -1, 0, }
);
cMillis = type;
}
return type;
}
|
[
"public",
"static",
"PeriodType",
"millis",
"(",
")",
"{",
"PeriodType",
"type",
"=",
"cMillis",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"type",
"=",
"new",
"PeriodType",
"(",
"\"Millis\"",
",",
"new",
"DurationFieldType",
"[",
"]",
"{",
"DurationFieldType",
".",
"millis",
"(",
")",
"}",
",",
"new",
"int",
"[",
"]",
"{",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
",",
"0",
",",
"}",
")",
";",
"cMillis",
"=",
"type",
";",
"}",
"return",
"type",
";",
"}"
] |
Gets a type that defines just the millis field.
@return the period type
|
[
"Gets",
"a",
"type",
"that",
"defines",
"just",
"the",
"millis",
"field",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/PeriodType.java#L479-L490
|
22,367
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/PeriodType.java
|
PeriodType.indexOf
|
public int indexOf(DurationFieldType type) {
for (int i = 0, isize = size(); i < isize; i++) {
if (iTypes[i] == type) {
return i;
}
}
return -1;
}
|
java
|
public int indexOf(DurationFieldType type) {
for (int i = 0, isize = size(); i < isize; i++) {
if (iTypes[i] == type) {
return i;
}
}
return -1;
}
|
[
"public",
"int",
"indexOf",
"(",
"DurationFieldType",
"type",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"isize",
"=",
"size",
"(",
")",
";",
"i",
"<",
"isize",
";",
"i",
"++",
")",
"{",
"if",
"(",
"iTypes",
"[",
"i",
"]",
"==",
"type",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Gets the index of the field in this period.
@param type the type to check, may be null which returns -1
@return the index of -1 if not supported
|
[
"Gets",
"the",
"index",
"of",
"the",
"field",
"in",
"this",
"period",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/PeriodType.java#L647-L654
|
22,368
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/PeriodType.java
|
PeriodType.getIndexedField
|
int getIndexedField(ReadablePeriod period, int index) {
int realIndex = iIndices[index];
return (realIndex == -1 ? 0 : period.getValue(realIndex));
}
|
java
|
int getIndexedField(ReadablePeriod period, int index) {
int realIndex = iIndices[index];
return (realIndex == -1 ? 0 : period.getValue(realIndex));
}
|
[
"int",
"getIndexedField",
"(",
"ReadablePeriod",
"period",
",",
"int",
"index",
")",
"{",
"int",
"realIndex",
"=",
"iIndices",
"[",
"index",
"]",
";",
"return",
"(",
"realIndex",
"==",
"-",
"1",
"?",
"0",
":",
"period",
".",
"getValue",
"(",
"realIndex",
")",
")",
";",
"}"
] |
Gets the indexed field part of the period.
@param period the period to query
@param index the index to use
@return the value of the field, zero if unsupported
|
[
"Gets",
"the",
"indexed",
"field",
"part",
"of",
"the",
"period",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/PeriodType.java#L673-L676
|
22,369
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/PeriodType.java
|
PeriodType.setIndexedField
|
boolean setIndexedField(ReadablePeriod period, int index, int[] values, int newValue) {
int realIndex = iIndices[index];
if (realIndex == -1) {
throw new UnsupportedOperationException("Field is not supported");
}
values[realIndex] = newValue;
return true;
}
|
java
|
boolean setIndexedField(ReadablePeriod period, int index, int[] values, int newValue) {
int realIndex = iIndices[index];
if (realIndex == -1) {
throw new UnsupportedOperationException("Field is not supported");
}
values[realIndex] = newValue;
return true;
}
|
[
"boolean",
"setIndexedField",
"(",
"ReadablePeriod",
"period",
",",
"int",
"index",
",",
"int",
"[",
"]",
"values",
",",
"int",
"newValue",
")",
"{",
"int",
"realIndex",
"=",
"iIndices",
"[",
"index",
"]",
";",
"if",
"(",
"realIndex",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Field is not supported\"",
")",
";",
"}",
"values",
"[",
"realIndex",
"]",
"=",
"newValue",
";",
"return",
"true",
";",
"}"
] |
Sets the indexed field part of the period.
@param period the period to query
@param index the index to use
@param values the array to populate
@param newValue the value to set
@throws UnsupportedOperationException if not supported
|
[
"Sets",
"the",
"indexed",
"field",
"part",
"of",
"the",
"period",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/PeriodType.java#L687-L694
|
22,370
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/PeriodType.java
|
PeriodType.addIndexedField
|
boolean addIndexedField(ReadablePeriod period, int index, int[] values, int valueToAdd) {
if (valueToAdd == 0) {
return false;
}
int realIndex = iIndices[index];
if (realIndex == -1) {
throw new UnsupportedOperationException("Field is not supported");
}
values[realIndex] = FieldUtils.safeAdd(values[realIndex], valueToAdd);
return true;
}
|
java
|
boolean addIndexedField(ReadablePeriod period, int index, int[] values, int valueToAdd) {
if (valueToAdd == 0) {
return false;
}
int realIndex = iIndices[index];
if (realIndex == -1) {
throw new UnsupportedOperationException("Field is not supported");
}
values[realIndex] = FieldUtils.safeAdd(values[realIndex], valueToAdd);
return true;
}
|
[
"boolean",
"addIndexedField",
"(",
"ReadablePeriod",
"period",
",",
"int",
"index",
",",
"int",
"[",
"]",
"values",
",",
"int",
"valueToAdd",
")",
"{",
"if",
"(",
"valueToAdd",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"int",
"realIndex",
"=",
"iIndices",
"[",
"index",
"]",
";",
"if",
"(",
"realIndex",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Field is not supported\"",
")",
";",
"}",
"values",
"[",
"realIndex",
"]",
"=",
"FieldUtils",
".",
"safeAdd",
"(",
"values",
"[",
"realIndex",
"]",
",",
"valueToAdd",
")",
";",
"return",
"true",
";",
"}"
] |
Adds to the indexed field part of the period.
@param period the period to query
@param index the index to use
@param values the array to populate
@param valueToAdd the value to add
@return true if the array is updated
@throws UnsupportedOperationException if not supported
|
[
"Adds",
"to",
"the",
"indexed",
"field",
"part",
"of",
"the",
"period",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/PeriodType.java#L706-L716
|
22,371
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/PeriodType.java
|
PeriodType.withFieldRemoved
|
private PeriodType withFieldRemoved(int indicesIndex, String name) {
int fieldIndex = iIndices[indicesIndex];
if (fieldIndex == -1) {
return this;
}
DurationFieldType[] types = new DurationFieldType[size() - 1];
for (int i = 0; i < iTypes.length; i++) {
if (i < fieldIndex) {
types[i] = iTypes[i];
} else if (i > fieldIndex) {
types[i - 1] = iTypes[i];
}
}
int[] indices = new int[8];
for (int i = 0; i < indices.length; i++) {
if (i < indicesIndex) {
indices[i] = iIndices[i];
} else if (i > indicesIndex) {
indices[i] = (iIndices[i] == -1 ? -1 : iIndices[i] - 1);
} else {
indices[i] = -1;
}
}
return new PeriodType(getName() + name, types, indices);
}
|
java
|
private PeriodType withFieldRemoved(int indicesIndex, String name) {
int fieldIndex = iIndices[indicesIndex];
if (fieldIndex == -1) {
return this;
}
DurationFieldType[] types = new DurationFieldType[size() - 1];
for (int i = 0; i < iTypes.length; i++) {
if (i < fieldIndex) {
types[i] = iTypes[i];
} else if (i > fieldIndex) {
types[i - 1] = iTypes[i];
}
}
int[] indices = new int[8];
for (int i = 0; i < indices.length; i++) {
if (i < indicesIndex) {
indices[i] = iIndices[i];
} else if (i > indicesIndex) {
indices[i] = (iIndices[i] == -1 ? -1 : iIndices[i] - 1);
} else {
indices[i] = -1;
}
}
return new PeriodType(getName() + name, types, indices);
}
|
[
"private",
"PeriodType",
"withFieldRemoved",
"(",
"int",
"indicesIndex",
",",
"String",
"name",
")",
"{",
"int",
"fieldIndex",
"=",
"iIndices",
"[",
"indicesIndex",
"]",
";",
"if",
"(",
"fieldIndex",
"==",
"-",
"1",
")",
"{",
"return",
"this",
";",
"}",
"DurationFieldType",
"[",
"]",
"types",
"=",
"new",
"DurationFieldType",
"[",
"size",
"(",
")",
"-",
"1",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"iTypes",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"<",
"fieldIndex",
")",
"{",
"types",
"[",
"i",
"]",
"=",
"iTypes",
"[",
"i",
"]",
";",
"}",
"else",
"if",
"(",
"i",
">",
"fieldIndex",
")",
"{",
"types",
"[",
"i",
"-",
"1",
"]",
"=",
"iTypes",
"[",
"i",
"]",
";",
"}",
"}",
"int",
"[",
"]",
"indices",
"=",
"new",
"int",
"[",
"8",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"indices",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"<",
"indicesIndex",
")",
"{",
"indices",
"[",
"i",
"]",
"=",
"iIndices",
"[",
"i",
"]",
";",
"}",
"else",
"if",
"(",
"i",
">",
"indicesIndex",
")",
"{",
"indices",
"[",
"i",
"]",
"=",
"(",
"iIndices",
"[",
"i",
"]",
"==",
"-",
"1",
"?",
"-",
"1",
":",
"iIndices",
"[",
"i",
"]",
"-",
"1",
")",
";",
"}",
"else",
"{",
"indices",
"[",
"i",
"]",
"=",
"-",
"1",
";",
"}",
"}",
"return",
"new",
"PeriodType",
"(",
"getName",
"(",
")",
"+",
"name",
",",
"types",
",",
"indices",
")",
";",
"}"
] |
Removes the field specified by indices index.
@param indicesIndex the index to remove
@param name the name addition
@return the new type
|
[
"Removes",
"the",
"field",
"specified",
"by",
"indices",
"index",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/PeriodType.java#L798-L824
|
22,372
|
JodaOrg/joda-time
|
src/example/org/joda/example/time/DateTimeBrowser.java
|
DateTimeBrowser.main
|
public static void main(String[] args) {
/*
* Developers Notes:
*
* -No corresponding Junit test class currently
* provided. Test by eyeball of the output.
*
* -Add a menu with Help(About)
* --> TBD.
*
* -Figure out some sane way to set initial default
* column sizes.
*
* -Lots of inner classes here, done in order to keep
* all the .class files easily identifiable. Some of
* this code is pretty ugly, very procedural in nature.
* Lots of very tight coupling between all the classes,
* thinly disguised switch statements, etc ..... This
* code written on the fly, with almost no thought given
* to OO design.
*
* -Also, I'm not really a GUI guy, so forgive any
* transgressions.
*
*/
if ( args.length < 1 ) {
System.err.println("File name is required!");
usage();
System.exit(1);
}
/*
* Instantiate a DateTimeBrowser and invoke it's go method,
* passing the input argument list.
*/
new DateTimeBrowser().go( args );
}
|
java
|
public static void main(String[] args) {
/*
* Developers Notes:
*
* -No corresponding Junit test class currently
* provided. Test by eyeball of the output.
*
* -Add a menu with Help(About)
* --> TBD.
*
* -Figure out some sane way to set initial default
* column sizes.
*
* -Lots of inner classes here, done in order to keep
* all the .class files easily identifiable. Some of
* this code is pretty ugly, very procedural in nature.
* Lots of very tight coupling between all the classes,
* thinly disguised switch statements, etc ..... This
* code written on the fly, with almost no thought given
* to OO design.
*
* -Also, I'm not really a GUI guy, so forgive any
* transgressions.
*
*/
if ( args.length < 1 ) {
System.err.println("File name is required!");
usage();
System.exit(1);
}
/*
* Instantiate a DateTimeBrowser and invoke it's go method,
* passing the input argument list.
*/
new DateTimeBrowser().go( args );
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"/*\n * Developers Notes:\n *\n * -No corresponding Junit test class currently\n * provided. Test by eyeball of the output.\n *\n * -Add a menu with Help(About)\n * --> TBD.\n *\n * -Figure out some sane way to set initial default\n * column sizes.\n *\n * -Lots of inner classes here, done in order to keep\n * all the .class files easily identifiable. Some of\n * this code is pretty ugly, very procedural in nature.\n * Lots of very tight coupling between all the classes,\n * thinly disguised switch statements, etc ..... This\n * code written on the fly, with almost no thought given\n * to OO design.\n *\n * -Also, I'm not really a GUI guy, so forgive any\n * transgressions.\n *\n */",
"if",
"(",
"args",
".",
"length",
"<",
"1",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"File name is required!\"",
")",
";",
"usage",
"(",
")",
";",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"/*\n * Instantiate a DateTimeBrowser and invoke it's go method,\n * passing the input argument list.\n */",
"new",
"DateTimeBrowser",
"(",
")",
".",
"go",
"(",
"args",
")",
";",
"}"
] |
This is the main swing application method. It sets up and displays the
initial GUI, and controls execution thereafter. Everything else in
this class is 'private', please read the code.
|
[
"This",
"is",
"the",
"main",
"swing",
"application",
"method",
".",
"It",
"sets",
"up",
"and",
"displays",
"the",
"initial",
"GUI",
"and",
"controls",
"execution",
"thereafter",
".",
"Everything",
"else",
"in",
"this",
"class",
"is",
"private",
"please",
"read",
"the",
"code",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/example/org/joda/example/time/DateTimeBrowser.java#L105-L140
|
22,373
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/UnsupportedDurationField.java
|
UnsupportedDurationField.getInstance
|
public static synchronized UnsupportedDurationField getInstance(DurationFieldType type) {
UnsupportedDurationField field;
if (cCache == null) {
cCache = new HashMap<DurationFieldType, UnsupportedDurationField>(7);
field = null;
} else {
field = cCache.get(type);
}
if (field == null) {
field = new UnsupportedDurationField(type);
cCache.put(type, field);
}
return field;
}
|
java
|
public static synchronized UnsupportedDurationField getInstance(DurationFieldType type) {
UnsupportedDurationField field;
if (cCache == null) {
cCache = new HashMap<DurationFieldType, UnsupportedDurationField>(7);
field = null;
} else {
field = cCache.get(type);
}
if (field == null) {
field = new UnsupportedDurationField(type);
cCache.put(type, field);
}
return field;
}
|
[
"public",
"static",
"synchronized",
"UnsupportedDurationField",
"getInstance",
"(",
"DurationFieldType",
"type",
")",
"{",
"UnsupportedDurationField",
"field",
";",
"if",
"(",
"cCache",
"==",
"null",
")",
"{",
"cCache",
"=",
"new",
"HashMap",
"<",
"DurationFieldType",
",",
"UnsupportedDurationField",
">",
"(",
"7",
")",
";",
"field",
"=",
"null",
";",
"}",
"else",
"{",
"field",
"=",
"cCache",
".",
"get",
"(",
"type",
")",
";",
"}",
"if",
"(",
"field",
"==",
"null",
")",
"{",
"field",
"=",
"new",
"UnsupportedDurationField",
"(",
"type",
")",
";",
"cCache",
".",
"put",
"(",
"type",
",",
"field",
")",
";",
"}",
"return",
"field",
";",
"}"
] |
Gets an instance of UnsupportedDurationField for a specific named field.
The returned instance is cached.
@param type the type to obtain
@return the instance
|
[
"Gets",
"an",
"instance",
"of",
"UnsupportedDurationField",
"for",
"a",
"specific",
"named",
"field",
".",
"The",
"returned",
"instance",
"is",
"cached",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/UnsupportedDurationField.java#L47-L60
|
22,374
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/tz/ZoneInfoProvider.java
|
ZoneInfoProvider.loadZoneData
|
private DateTimeZone loadZoneData(String id) {
InputStream in = null;
try {
in = openResource(id);
DateTimeZone tz = DateTimeZoneBuilder.readFrom(in, id);
iZoneInfoMap.put(id, new SoftReference<DateTimeZone>(tz));
return tz;
} catch (IOException ex) {
uncaughtException(ex);
iZoneInfoMap.remove(id);
return null;
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException ex) {
}
}
}
|
java
|
private DateTimeZone loadZoneData(String id) {
InputStream in = null;
try {
in = openResource(id);
DateTimeZone tz = DateTimeZoneBuilder.readFrom(in, id);
iZoneInfoMap.put(id, new SoftReference<DateTimeZone>(tz));
return tz;
} catch (IOException ex) {
uncaughtException(ex);
iZoneInfoMap.remove(id);
return null;
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException ex) {
}
}
}
|
[
"private",
"DateTimeZone",
"loadZoneData",
"(",
"String",
"id",
")",
"{",
"InputStream",
"in",
"=",
"null",
";",
"try",
"{",
"in",
"=",
"openResource",
"(",
"id",
")",
";",
"DateTimeZone",
"tz",
"=",
"DateTimeZoneBuilder",
".",
"readFrom",
"(",
"in",
",",
"id",
")",
";",
"iZoneInfoMap",
".",
"put",
"(",
"id",
",",
"new",
"SoftReference",
"<",
"DateTimeZone",
">",
"(",
"tz",
")",
")",
";",
"return",
"tz",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"uncaughtException",
"(",
"ex",
")",
";",
"iZoneInfoMap",
".",
"remove",
"(",
"id",
")",
";",
"return",
"null",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"in",
"!=",
"null",
")",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"}",
"}",
"}"
] |
Loads the time zone data for one id.
@param id the id to load
@return the zone
|
[
"Loads",
"the",
"time",
"zone",
"data",
"for",
"one",
"id",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/tz/ZoneInfoProvider.java#L237-L256
|
22,375
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/tz/ZoneInfoProvider.java
|
ZoneInfoProvider.loadZoneInfoMap
|
private static Map<String, Object> loadZoneInfoMap(InputStream in) throws IOException {
Map<String, Object> map = new ConcurrentHashMap<String, Object>();
DataInputStream din = new DataInputStream(in);
try {
readZoneInfoMap(din, map);
} finally {
try {
din.close();
} catch (IOException ex) {
}
}
map.put("UTC", new SoftReference<DateTimeZone>(DateTimeZone.UTC));
return map;
}
|
java
|
private static Map<String, Object> loadZoneInfoMap(InputStream in) throws IOException {
Map<String, Object> map = new ConcurrentHashMap<String, Object>();
DataInputStream din = new DataInputStream(in);
try {
readZoneInfoMap(din, map);
} finally {
try {
din.close();
} catch (IOException ex) {
}
}
map.put("UTC", new SoftReference<DateTimeZone>(DateTimeZone.UTC));
return map;
}
|
[
"private",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"loadZoneInfoMap",
"(",
"InputStream",
"in",
")",
"throws",
"IOException",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"new",
"ConcurrentHashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"DataInputStream",
"din",
"=",
"new",
"DataInputStream",
"(",
"in",
")",
";",
"try",
"{",
"readZoneInfoMap",
"(",
"din",
",",
"map",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"din",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"}",
"}",
"map",
".",
"put",
"(",
"\"UTC\"",
",",
"new",
"SoftReference",
"<",
"DateTimeZone",
">",
"(",
"DateTimeZone",
".",
"UTC",
")",
")",
";",
"return",
"map",
";",
"}"
] |
Loads the zone info map.
@param in the input stream
@return the map
|
[
"Loads",
"the",
"zone",
"info",
"map",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/tz/ZoneInfoProvider.java#L265-L278
|
22,376
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/tz/ZoneInfoProvider.java
|
ZoneInfoProvider.readZoneInfoMap
|
private static void readZoneInfoMap(DataInputStream din, Map<String, Object> zimap) throws IOException {
// Read the string pool.
int size = din.readUnsignedShort();
String[] pool = new String[size];
for (int i=0; i<size; i++) {
pool[i] = din.readUTF().intern();
}
// Read the mappings.
size = din.readUnsignedShort();
for (int i=0; i<size; i++) {
try {
zimap.put(pool[din.readUnsignedShort()], pool[din.readUnsignedShort()]);
} catch (ArrayIndexOutOfBoundsException ex) {
throw new IOException("Corrupt zone info map");
}
}
}
|
java
|
private static void readZoneInfoMap(DataInputStream din, Map<String, Object> zimap) throws IOException {
// Read the string pool.
int size = din.readUnsignedShort();
String[] pool = new String[size];
for (int i=0; i<size; i++) {
pool[i] = din.readUTF().intern();
}
// Read the mappings.
size = din.readUnsignedShort();
for (int i=0; i<size; i++) {
try {
zimap.put(pool[din.readUnsignedShort()], pool[din.readUnsignedShort()]);
} catch (ArrayIndexOutOfBoundsException ex) {
throw new IOException("Corrupt zone info map");
}
}
}
|
[
"private",
"static",
"void",
"readZoneInfoMap",
"(",
"DataInputStream",
"din",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"zimap",
")",
"throws",
"IOException",
"{",
"// Read the string pool.",
"int",
"size",
"=",
"din",
".",
"readUnsignedShort",
"(",
")",
";",
"String",
"[",
"]",
"pool",
"=",
"new",
"String",
"[",
"size",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"pool",
"[",
"i",
"]",
"=",
"din",
".",
"readUTF",
"(",
")",
".",
"intern",
"(",
")",
";",
"}",
"// Read the mappings.",
"size",
"=",
"din",
".",
"readUnsignedShort",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"try",
"{",
"zimap",
".",
"put",
"(",
"pool",
"[",
"din",
".",
"readUnsignedShort",
"(",
")",
"]",
",",
"pool",
"[",
"din",
".",
"readUnsignedShort",
"(",
")",
"]",
")",
";",
"}",
"catch",
"(",
"ArrayIndexOutOfBoundsException",
"ex",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Corrupt zone info map\"",
")",
";",
"}",
"}",
"}"
] |
Reads the zone info map from file.
@param din the input stream
@param zimap gets filled with string id to string id mappings
|
[
"Reads",
"the",
"zone",
"info",
"map",
"from",
"file",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/tz/ZoneInfoProvider.java#L286-L303
|
22,377
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/RemainderDateTimeField.java
|
RemainderDateTimeField.addWrapField
|
public long addWrapField(long instant, int amount) {
return set(instant, FieldUtils.getWrappedValue(get(instant), amount, 0, iDivisor - 1));
}
|
java
|
public long addWrapField(long instant, int amount) {
return set(instant, FieldUtils.getWrappedValue(get(instant), amount, 0, iDivisor - 1));
}
|
[
"public",
"long",
"addWrapField",
"(",
"long",
"instant",
",",
"int",
"amount",
")",
"{",
"return",
"set",
"(",
"instant",
",",
"FieldUtils",
".",
"getWrappedValue",
"(",
"get",
"(",
"instant",
")",
",",
"amount",
",",
"0",
",",
"iDivisor",
"-",
"1",
")",
")",
";",
"}"
] |
Add the specified amount to the specified time instant, wrapping around
within the remainder range if necessary. The amount added may be
negative.
@param instant the time instant in millis to update.
@param amount the amount to add (can be negative).
@return the updated time instant.
|
[
"Add",
"the",
"specified",
"amount",
"to",
"the",
"specified",
"time",
"instant",
"wrapping",
"around",
"within",
"the",
"remainder",
"range",
"if",
"necessary",
".",
"The",
"amount",
"added",
"may",
"be",
"negative",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/RemainderDateTimeField.java#L153-L155
|
22,378
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/RemainderDateTimeField.java
|
RemainderDateTimeField.set
|
public long set(long instant, int value) {
FieldUtils.verifyValueBounds(this, value, 0, iDivisor - 1);
int divided = getDivided(getWrappedField().get(instant));
return getWrappedField().set(instant, divided * iDivisor + value);
}
|
java
|
public long set(long instant, int value) {
FieldUtils.verifyValueBounds(this, value, 0, iDivisor - 1);
int divided = getDivided(getWrappedField().get(instant));
return getWrappedField().set(instant, divided * iDivisor + value);
}
|
[
"public",
"long",
"set",
"(",
"long",
"instant",
",",
"int",
"value",
")",
"{",
"FieldUtils",
".",
"verifyValueBounds",
"(",
"this",
",",
"value",
",",
"0",
",",
"iDivisor",
"-",
"1",
")",
";",
"int",
"divided",
"=",
"getDivided",
"(",
"getWrappedField",
"(",
")",
".",
"get",
"(",
"instant",
")",
")",
";",
"return",
"getWrappedField",
"(",
")",
".",
"set",
"(",
"instant",
",",
"divided",
"*",
"iDivisor",
"+",
"value",
")",
";",
"}"
] |
Set the specified amount of remainder units to the specified time instant.
@param instant the time instant in millis to update.
@param value value of remainder units to set.
@return the updated time instant.
@throws IllegalArgumentException if value is too large or too small.
|
[
"Set",
"the",
"specified",
"amount",
"of",
"remainder",
"units",
"to",
"the",
"specified",
"time",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/RemainderDateTimeField.java#L165-L169
|
22,379
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/Period.java
|
Period.multipliedBy
|
public Period multipliedBy(int scalar) {
if (this == ZERO || scalar == 1) {
return this;
}
int[] values = getValues(); // cloned
for (int i = 0; i < values.length; i++) {
values[i] = FieldUtils.safeMultiply(values[i], scalar);
}
return new Period(values, getPeriodType());
}
|
java
|
public Period multipliedBy(int scalar) {
if (this == ZERO || scalar == 1) {
return this;
}
int[] values = getValues(); // cloned
for (int i = 0; i < values.length; i++) {
values[i] = FieldUtils.safeMultiply(values[i], scalar);
}
return new Period(values, getPeriodType());
}
|
[
"public",
"Period",
"multipliedBy",
"(",
"int",
"scalar",
")",
"{",
"if",
"(",
"this",
"==",
"ZERO",
"||",
"scalar",
"==",
"1",
")",
"{",
"return",
"this",
";",
"}",
"int",
"[",
"]",
"values",
"=",
"getValues",
"(",
")",
";",
"// cloned",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"length",
";",
"i",
"++",
")",
"{",
"values",
"[",
"i",
"]",
"=",
"FieldUtils",
".",
"safeMultiply",
"(",
"values",
"[",
"i",
"]",
",",
"scalar",
")",
";",
"}",
"return",
"new",
"Period",
"(",
"values",
",",
"getPeriodType",
"(",
")",
")",
";",
"}"
] |
Returns a new instance with each element in this period multiplied
by the specified scalar.
@param scalar the scalar to multiply by, not null
@return a {@code Period} based on this period with the amounts multiplied by the scalar, never null
@throws ArithmeticException if the capacity of any field is exceeded
@since 2.1
|
[
"Returns",
"a",
"new",
"instance",
"with",
"each",
"element",
"in",
"this",
"period",
"multiplied",
"by",
"the",
"specified",
"scalar",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Period.java#L1353-L1362
|
22,380
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/DividedDateTimeField.java
|
DividedDateTimeField.get
|
public int get(long instant) {
int value = getWrappedField().get(instant);
if (value >= 0) {
return value / iDivisor;
} else {
return ((value + 1) / iDivisor) - 1;
}
}
|
java
|
public int get(long instant) {
int value = getWrappedField().get(instant);
if (value >= 0) {
return value / iDivisor;
} else {
return ((value + 1) / iDivisor) - 1;
}
}
|
[
"public",
"int",
"get",
"(",
"long",
"instant",
")",
"{",
"int",
"value",
"=",
"getWrappedField",
"(",
")",
".",
"get",
"(",
"instant",
")",
";",
"if",
"(",
"value",
">=",
"0",
")",
"{",
"return",
"value",
"/",
"iDivisor",
";",
"}",
"else",
"{",
"return",
"(",
"(",
"value",
"+",
"1",
")",
"/",
"iDivisor",
")",
"-",
"1",
";",
"}",
"}"
] |
Get the amount of scaled units from the specified time instant.
@param instant the time instant in millis to query.
@return the amount of scaled units extracted from the input.
|
[
"Get",
"the",
"amount",
"of",
"scaled",
"units",
"from",
"the",
"specified",
"time",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/DividedDateTimeField.java#L140-L147
|
22,381
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/DividedDateTimeField.java
|
DividedDateTimeField.addWrapField
|
public long addWrapField(long instant, int amount) {
return set(instant, FieldUtils.getWrappedValue(get(instant), amount, iMin, iMax));
}
|
java
|
public long addWrapField(long instant, int amount) {
return set(instant, FieldUtils.getWrappedValue(get(instant), amount, iMin, iMax));
}
|
[
"public",
"long",
"addWrapField",
"(",
"long",
"instant",
",",
"int",
"amount",
")",
"{",
"return",
"set",
"(",
"instant",
",",
"FieldUtils",
".",
"getWrappedValue",
"(",
"get",
"(",
"instant",
")",
",",
"amount",
",",
"iMin",
",",
"iMax",
")",
")",
";",
"}"
] |
Add to the scaled component of the specified time instant,
wrapping around within that component if necessary.
@param instant the time instant in millis to update.
@param amount the amount of scaled units to add (can be negative).
@return the updated time instant.
|
[
"Add",
"to",
"the",
"scaled",
"component",
"of",
"the",
"specified",
"time",
"instant",
"wrapping",
"around",
"within",
"that",
"component",
"if",
"necessary",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/DividedDateTimeField.java#L181-L183
|
22,382
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/DividedDateTimeField.java
|
DividedDateTimeField.set
|
public long set(long instant, int value) {
FieldUtils.verifyValueBounds(this, value, iMin, iMax);
int remainder = getRemainder(getWrappedField().get(instant));
return getWrappedField().set(instant, value * iDivisor + remainder);
}
|
java
|
public long set(long instant, int value) {
FieldUtils.verifyValueBounds(this, value, iMin, iMax);
int remainder = getRemainder(getWrappedField().get(instant));
return getWrappedField().set(instant, value * iDivisor + remainder);
}
|
[
"public",
"long",
"set",
"(",
"long",
"instant",
",",
"int",
"value",
")",
"{",
"FieldUtils",
".",
"verifyValueBounds",
"(",
"this",
",",
"value",
",",
"iMin",
",",
"iMax",
")",
";",
"int",
"remainder",
"=",
"getRemainder",
"(",
"getWrappedField",
"(",
")",
".",
"get",
"(",
"instant",
")",
")",
";",
"return",
"getWrappedField",
"(",
")",
".",
"set",
"(",
"instant",
",",
"value",
"*",
"iDivisor",
"+",
"remainder",
")",
";",
"}"
] |
Set the specified amount of scaled units to the specified time instant.
@param instant the time instant in millis to update.
@param value value of scaled units to set.
@return the updated time instant.
@throws IllegalArgumentException if value is too large or too small.
|
[
"Set",
"the",
"specified",
"amount",
"of",
"scaled",
"units",
"to",
"the",
"specified",
"time",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/DividedDateTimeField.java#L201-L205
|
22,383
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/convert/ReadableInstantConverter.java
|
ReadableInstantConverter.getChronology
|
public Chronology getChronology(Object object, DateTimeZone zone) {
Chronology chrono = ((ReadableInstant) object).getChronology();
if (chrono == null) {
return ISOChronology.getInstance(zone);
}
DateTimeZone chronoZone = chrono.getZone();
if (chronoZone != zone) {
chrono = chrono.withZone(zone);
if (chrono == null) {
return ISOChronology.getInstance(zone);
}
}
return chrono;
}
|
java
|
public Chronology getChronology(Object object, DateTimeZone zone) {
Chronology chrono = ((ReadableInstant) object).getChronology();
if (chrono == null) {
return ISOChronology.getInstance(zone);
}
DateTimeZone chronoZone = chrono.getZone();
if (chronoZone != zone) {
chrono = chrono.withZone(zone);
if (chrono == null) {
return ISOChronology.getInstance(zone);
}
}
return chrono;
}
|
[
"public",
"Chronology",
"getChronology",
"(",
"Object",
"object",
",",
"DateTimeZone",
"zone",
")",
"{",
"Chronology",
"chrono",
"=",
"(",
"(",
"ReadableInstant",
")",
"object",
")",
".",
"getChronology",
"(",
")",
";",
"if",
"(",
"chrono",
"==",
"null",
")",
"{",
"return",
"ISOChronology",
".",
"getInstance",
"(",
"zone",
")",
";",
"}",
"DateTimeZone",
"chronoZone",
"=",
"chrono",
".",
"getZone",
"(",
")",
";",
"if",
"(",
"chronoZone",
"!=",
"zone",
")",
"{",
"chrono",
"=",
"chrono",
".",
"withZone",
"(",
"zone",
")",
";",
"if",
"(",
"chrono",
"==",
"null",
")",
"{",
"return",
"ISOChronology",
".",
"getInstance",
"(",
"zone",
")",
";",
"}",
"}",
"return",
"chrono",
";",
"}"
] |
Gets the chronology, which is taken from the ReadableInstant.
If the chronology on the instant is null, the ISOChronology in the
specified time zone is used.
If the chronology on the instant is not in the specified zone, it is
adapted.
@param object the ReadableInstant to convert, must not be null
@param zone the specified zone to use, null means default zone
@return the chronology, never null
|
[
"Gets",
"the",
"chronology",
"which",
"is",
"taken",
"from",
"the",
"ReadableInstant",
".",
"If",
"the",
"chronology",
"on",
"the",
"instant",
"is",
"null",
"the",
"ISOChronology",
"in",
"the",
"specified",
"time",
"zone",
"is",
"used",
".",
"If",
"the",
"chronology",
"on",
"the",
"instant",
"is",
"not",
"in",
"the",
"specified",
"zone",
"it",
"is",
"adapted",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/ReadableInstantConverter.java#L57-L70
|
22,384
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/convert/ReadablePeriodConverter.java
|
ReadablePeriodConverter.setInto
|
public void setInto(ReadWritablePeriod duration, Object object, Chronology chrono) {
duration.setPeriod((ReadablePeriod) object);
}
|
java
|
public void setInto(ReadWritablePeriod duration, Object object, Chronology chrono) {
duration.setPeriod((ReadablePeriod) object);
}
|
[
"public",
"void",
"setInto",
"(",
"ReadWritablePeriod",
"duration",
",",
"Object",
"object",
",",
"Chronology",
"chrono",
")",
"{",
"duration",
".",
"setPeriod",
"(",
"(",
"ReadablePeriod",
")",
"object",
")",
";",
"}"
] |
Extracts duration values from an object of this converter's type, and
sets them into the given ReadWritablePeriod.
@param duration duration to get modified
@param object the object to convert, must not be null
@param chrono the chronology to use
@throws NullPointerException if the duration or object is null
@throws ClassCastException if the object is an invalid type
@throws IllegalArgumentException if the object is invalid
|
[
"Extracts",
"duration",
"values",
"from",
"an",
"object",
"of",
"this",
"converter",
"s",
"type",
"and",
"sets",
"them",
"into",
"the",
"given",
"ReadWritablePeriod",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/ReadablePeriodConverter.java#L57-L59
|
22,385
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/convert/ReadablePeriodConverter.java
|
ReadablePeriodConverter.getPeriodType
|
public PeriodType getPeriodType(Object object) {
ReadablePeriod period = (ReadablePeriod) object;
return period.getPeriodType();
}
|
java
|
public PeriodType getPeriodType(Object object) {
ReadablePeriod period = (ReadablePeriod) object;
return period.getPeriodType();
}
|
[
"public",
"PeriodType",
"getPeriodType",
"(",
"Object",
"object",
")",
"{",
"ReadablePeriod",
"period",
"=",
"(",
"ReadablePeriod",
")",
"object",
";",
"return",
"period",
".",
"getPeriodType",
"(",
")",
";",
"}"
] |
Selects a suitable period type for the given object.
@param object the object to examine, must not be null
@return the period type from the readable duration
@throws NullPointerException if the object is null
@throws ClassCastException if the object is an invalid type
|
[
"Selects",
"a",
"suitable",
"period",
"type",
"for",
"the",
"given",
"object",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/convert/ReadablePeriodConverter.java#L69-L72
|
22,386
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/OffsetDateTimeField.java
|
OffsetDateTimeField.add
|
public long add(long instant, int amount) {
instant = super.add(instant, amount);
FieldUtils.verifyValueBounds(this, get(instant), iMin, iMax);
return instant;
}
|
java
|
public long add(long instant, int amount) {
instant = super.add(instant, amount);
FieldUtils.verifyValueBounds(this, get(instant), iMin, iMax);
return instant;
}
|
[
"public",
"long",
"add",
"(",
"long",
"instant",
",",
"int",
"amount",
")",
"{",
"instant",
"=",
"super",
".",
"add",
"(",
"instant",
",",
"amount",
")",
";",
"FieldUtils",
".",
"verifyValueBounds",
"(",
"this",
",",
"get",
"(",
"instant",
")",
",",
"iMin",
",",
"iMax",
")",
";",
"return",
"instant",
";",
"}"
] |
Add the specified amount of offset units to the specified time
instant. The amount added may be negative.
@param instant the time instant in millis to update.
@param amount the amount of units to add (can be negative).
@return the updated time instant.
|
[
"Add",
"the",
"specified",
"amount",
"of",
"offset",
"units",
"to",
"the",
"specified",
"time",
"instant",
".",
"The",
"amount",
"added",
"may",
"be",
"negative",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/OffsetDateTimeField.java#L112-L116
|
22,387
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/OffsetDateTimeField.java
|
OffsetDateTimeField.set
|
public long set(long instant, int value) {
FieldUtils.verifyValueBounds(this, value, iMin, iMax);
return super.set(instant, value - iOffset);
}
|
java
|
public long set(long instant, int value) {
FieldUtils.verifyValueBounds(this, value, iMin, iMax);
return super.set(instant, value - iOffset);
}
|
[
"public",
"long",
"set",
"(",
"long",
"instant",
",",
"int",
"value",
")",
"{",
"FieldUtils",
".",
"verifyValueBounds",
"(",
"this",
",",
"value",
",",
"iMin",
",",
"iMax",
")",
";",
"return",
"super",
".",
"set",
"(",
"instant",
",",
"value",
"-",
"iOffset",
")",
";",
"}"
] |
Set the specified amount of offset units to the specified time instant.
@param instant the time instant in millis to update.
@param value value of units to set.
@return the updated time instant.
@throws IllegalArgumentException if value is too large or too small.
|
[
"Set",
"the",
"specified",
"amount",
"of",
"offset",
"units",
"to",
"the",
"specified",
"time",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/OffsetDateTimeField.java#L152-L155
|
22,388
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/UnsupportedDateTimeField.java
|
UnsupportedDateTimeField.getInstance
|
public static synchronized UnsupportedDateTimeField getInstance(
DateTimeFieldType type, DurationField durationField) {
UnsupportedDateTimeField field;
if (cCache == null) {
cCache = new HashMap<DateTimeFieldType, UnsupportedDateTimeField>(7);
field = null;
} else {
field = cCache.get(type);
if (field != null && field.getDurationField() != durationField) {
field = null;
}
}
if (field == null) {
field = new UnsupportedDateTimeField(type, durationField);
cCache.put(type, field);
}
return field;
}
|
java
|
public static synchronized UnsupportedDateTimeField getInstance(
DateTimeFieldType type, DurationField durationField) {
UnsupportedDateTimeField field;
if (cCache == null) {
cCache = new HashMap<DateTimeFieldType, UnsupportedDateTimeField>(7);
field = null;
} else {
field = cCache.get(type);
if (field != null && field.getDurationField() != durationField) {
field = null;
}
}
if (field == null) {
field = new UnsupportedDateTimeField(type, durationField);
cCache.put(type, field);
}
return field;
}
|
[
"public",
"static",
"synchronized",
"UnsupportedDateTimeField",
"getInstance",
"(",
"DateTimeFieldType",
"type",
",",
"DurationField",
"durationField",
")",
"{",
"UnsupportedDateTimeField",
"field",
";",
"if",
"(",
"cCache",
"==",
"null",
")",
"{",
"cCache",
"=",
"new",
"HashMap",
"<",
"DateTimeFieldType",
",",
"UnsupportedDateTimeField",
">",
"(",
"7",
")",
";",
"field",
"=",
"null",
";",
"}",
"else",
"{",
"field",
"=",
"cCache",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"field",
"!=",
"null",
"&&",
"field",
".",
"getDurationField",
"(",
")",
"!=",
"durationField",
")",
"{",
"field",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"field",
"==",
"null",
")",
"{",
"field",
"=",
"new",
"UnsupportedDateTimeField",
"(",
"type",
",",
"durationField",
")",
";",
"cCache",
".",
"put",
"(",
"type",
",",
"field",
")",
";",
"}",
"return",
"field",
";",
"}"
] |
Gets an instance of UnsupportedDateTimeField for a specific named field.
Names should be of standard format, such as 'monthOfYear' or 'hourOfDay'.
The returned instance is cached.
@param type the type to obtain
@return the instance
@throws IllegalArgumentException if durationField is null
|
[
"Gets",
"an",
"instance",
"of",
"UnsupportedDateTimeField",
"for",
"a",
"specific",
"named",
"field",
".",
"Names",
"should",
"be",
"of",
"standard",
"format",
"such",
"as",
"monthOfYear",
"or",
"hourOfDay",
".",
"The",
"returned",
"instance",
"is",
"cached",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/UnsupportedDateTimeField.java#L51-L69
|
22,389
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/UnsupportedDateTimeField.java
|
UnsupportedDateTimeField.set
|
public int[] set(ReadablePartial instant, int fieldIndex, int[] values, String text, Locale locale) {
throw unsupported();
}
|
java
|
public int[] set(ReadablePartial instant, int fieldIndex, int[] values, String text, Locale locale) {
throw unsupported();
}
|
[
"public",
"int",
"[",
"]",
"set",
"(",
"ReadablePartial",
"instant",
",",
"int",
"fieldIndex",
",",
"int",
"[",
"]",
"values",
",",
"String",
"text",
",",
"Locale",
"locale",
")",
"{",
"throw",
"unsupported",
"(",
")",
";",
"}"
] |
Always throws UnsupportedOperationException
@throws UnsupportedOperationException
|
[
"Always",
"throws",
"UnsupportedOperationException"
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/UnsupportedDateTimeField.java#L332-L334
|
22,390
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/Interval.java
|
Interval.withChronology
|
public Interval withChronology(Chronology chronology) {
if (getChronology() == chronology) {
return this;
}
return new Interval(getStartMillis(), getEndMillis(), chronology);
}
|
java
|
public Interval withChronology(Chronology chronology) {
if (getChronology() == chronology) {
return this;
}
return new Interval(getStartMillis(), getEndMillis(), chronology);
}
|
[
"public",
"Interval",
"withChronology",
"(",
"Chronology",
"chronology",
")",
"{",
"if",
"(",
"getChronology",
"(",
")",
"==",
"chronology",
")",
"{",
"return",
"this",
";",
"}",
"return",
"new",
"Interval",
"(",
"getStartMillis",
"(",
")",
",",
"getEndMillis",
"(",
")",
",",
"chronology",
")",
";",
"}"
] |
Creates a new interval with the same start and end, but a different chronology.
@param chronology the chronology to use, null means ISO default
@return an interval with a different chronology
|
[
"Creates",
"a",
"new",
"interval",
"with",
"the",
"same",
"start",
"and",
"end",
"but",
"a",
"different",
"chronology",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Interval.java#L431-L436
|
22,391
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/Interval.java
|
Interval.withStart
|
public Interval withStart(ReadableInstant start) {
long startMillis = DateTimeUtils.getInstantMillis(start);
return withStartMillis(startMillis);
}
|
java
|
public Interval withStart(ReadableInstant start) {
long startMillis = DateTimeUtils.getInstantMillis(start);
return withStartMillis(startMillis);
}
|
[
"public",
"Interval",
"withStart",
"(",
"ReadableInstant",
"start",
")",
"{",
"long",
"startMillis",
"=",
"DateTimeUtils",
".",
"getInstantMillis",
"(",
"start",
")",
";",
"return",
"withStartMillis",
"(",
"startMillis",
")",
";",
"}"
] |
Creates a new interval with the specified start instant.
@param start the start instant for the new interval, null means now
@return an interval with the end from this interval and the specified start
@throws IllegalArgumentException if the resulting interval has end before start
|
[
"Creates",
"a",
"new",
"interval",
"with",
"the",
"specified",
"start",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Interval.java#L459-L462
|
22,392
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/Interval.java
|
Interval.withEnd
|
public Interval withEnd(ReadableInstant end) {
long endMillis = DateTimeUtils.getInstantMillis(end);
return withEndMillis(endMillis);
}
|
java
|
public Interval withEnd(ReadableInstant end) {
long endMillis = DateTimeUtils.getInstantMillis(end);
return withEndMillis(endMillis);
}
|
[
"public",
"Interval",
"withEnd",
"(",
"ReadableInstant",
"end",
")",
"{",
"long",
"endMillis",
"=",
"DateTimeUtils",
".",
"getInstantMillis",
"(",
"end",
")",
";",
"return",
"withEndMillis",
"(",
"endMillis",
")",
";",
"}"
] |
Creates a new interval with the specified end instant.
@param end the end instant for the new interval, null means now
@return an interval with the start from this interval and the specified end
@throws IllegalArgumentException if the resulting interval has end before start
|
[
"Creates",
"a",
"new",
"interval",
"with",
"the",
"specified",
"end",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Interval.java#L485-L488
|
22,393
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/Interval.java
|
Interval.withDurationAfterStart
|
public Interval withDurationAfterStart(ReadableDuration duration) {
long durationMillis = DateTimeUtils.getDurationMillis(duration);
if (durationMillis == toDurationMillis()) {
return this;
}
Chronology chrono = getChronology();
long startMillis = getStartMillis();
long endMillis = chrono.add(startMillis, durationMillis, 1);
return new Interval(startMillis, endMillis, chrono);
}
|
java
|
public Interval withDurationAfterStart(ReadableDuration duration) {
long durationMillis = DateTimeUtils.getDurationMillis(duration);
if (durationMillis == toDurationMillis()) {
return this;
}
Chronology chrono = getChronology();
long startMillis = getStartMillis();
long endMillis = chrono.add(startMillis, durationMillis, 1);
return new Interval(startMillis, endMillis, chrono);
}
|
[
"public",
"Interval",
"withDurationAfterStart",
"(",
"ReadableDuration",
"duration",
")",
"{",
"long",
"durationMillis",
"=",
"DateTimeUtils",
".",
"getDurationMillis",
"(",
"duration",
")",
";",
"if",
"(",
"durationMillis",
"==",
"toDurationMillis",
"(",
")",
")",
"{",
"return",
"this",
";",
"}",
"Chronology",
"chrono",
"=",
"getChronology",
"(",
")",
";",
"long",
"startMillis",
"=",
"getStartMillis",
"(",
")",
";",
"long",
"endMillis",
"=",
"chrono",
".",
"add",
"(",
"startMillis",
",",
"durationMillis",
",",
"1",
")",
";",
"return",
"new",
"Interval",
"(",
"startMillis",
",",
"endMillis",
",",
"chrono",
")",
";",
"}"
] |
Creates a new interval with the specified duration after the start instant.
@param duration the duration to add to the start to get the new end instant, null means zero
@return an interval with the start from this interval and a calculated end
@throws IllegalArgumentException if the duration is negative
|
[
"Creates",
"a",
"new",
"interval",
"with",
"the",
"specified",
"duration",
"after",
"the",
"start",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Interval.java#L498-L507
|
22,394
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/Interval.java
|
Interval.withDurationBeforeEnd
|
public Interval withDurationBeforeEnd(ReadableDuration duration) {
long durationMillis = DateTimeUtils.getDurationMillis(duration);
if (durationMillis == toDurationMillis()) {
return this;
}
Chronology chrono = getChronology();
long endMillis = getEndMillis();
long startMillis = chrono.add(endMillis, durationMillis, -1);
return new Interval(startMillis, endMillis, chrono);
}
|
java
|
public Interval withDurationBeforeEnd(ReadableDuration duration) {
long durationMillis = DateTimeUtils.getDurationMillis(duration);
if (durationMillis == toDurationMillis()) {
return this;
}
Chronology chrono = getChronology();
long endMillis = getEndMillis();
long startMillis = chrono.add(endMillis, durationMillis, -1);
return new Interval(startMillis, endMillis, chrono);
}
|
[
"public",
"Interval",
"withDurationBeforeEnd",
"(",
"ReadableDuration",
"duration",
")",
"{",
"long",
"durationMillis",
"=",
"DateTimeUtils",
".",
"getDurationMillis",
"(",
"duration",
")",
";",
"if",
"(",
"durationMillis",
"==",
"toDurationMillis",
"(",
")",
")",
"{",
"return",
"this",
";",
"}",
"Chronology",
"chrono",
"=",
"getChronology",
"(",
")",
";",
"long",
"endMillis",
"=",
"getEndMillis",
"(",
")",
";",
"long",
"startMillis",
"=",
"chrono",
".",
"add",
"(",
"endMillis",
",",
"durationMillis",
",",
"-",
"1",
")",
";",
"return",
"new",
"Interval",
"(",
"startMillis",
",",
"endMillis",
",",
"chrono",
")",
";",
"}"
] |
Creates a new interval with the specified duration before the end instant.
@param duration the duration to subtract from the end to get the new start instant, null means zero
@return an interval with the end from this interval and a calculated start
@throws IllegalArgumentException if the duration is negative
|
[
"Creates",
"a",
"new",
"interval",
"with",
"the",
"specified",
"duration",
"before",
"the",
"end",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Interval.java#L516-L525
|
22,395
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/Interval.java
|
Interval.withPeriodAfterStart
|
public Interval withPeriodAfterStart(ReadablePeriod period) {
if (period == null) {
return withDurationAfterStart(null);
}
Chronology chrono = getChronology();
long startMillis = getStartMillis();
long endMillis = chrono.add(period, startMillis, 1);
return new Interval(startMillis, endMillis, chrono);
}
|
java
|
public Interval withPeriodAfterStart(ReadablePeriod period) {
if (period == null) {
return withDurationAfterStart(null);
}
Chronology chrono = getChronology();
long startMillis = getStartMillis();
long endMillis = chrono.add(period, startMillis, 1);
return new Interval(startMillis, endMillis, chrono);
}
|
[
"public",
"Interval",
"withPeriodAfterStart",
"(",
"ReadablePeriod",
"period",
")",
"{",
"if",
"(",
"period",
"==",
"null",
")",
"{",
"return",
"withDurationAfterStart",
"(",
"null",
")",
";",
"}",
"Chronology",
"chrono",
"=",
"getChronology",
"(",
")",
";",
"long",
"startMillis",
"=",
"getStartMillis",
"(",
")",
";",
"long",
"endMillis",
"=",
"chrono",
".",
"add",
"(",
"period",
",",
"startMillis",
",",
"1",
")",
";",
"return",
"new",
"Interval",
"(",
"startMillis",
",",
"endMillis",
",",
"chrono",
")",
";",
"}"
] |
Creates a new interval with the specified period after the start instant.
@param period the period to add to the start to get the new end instant, null means zero
@return an interval with the start from this interval and a calculated end
@throws IllegalArgumentException if the period is negative
|
[
"Creates",
"a",
"new",
"interval",
"with",
"the",
"specified",
"period",
"after",
"the",
"start",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Interval.java#L535-L543
|
22,396
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/Interval.java
|
Interval.withPeriodBeforeEnd
|
public Interval withPeriodBeforeEnd(ReadablePeriod period) {
if (period == null) {
return withDurationBeforeEnd(null);
}
Chronology chrono = getChronology();
long endMillis = getEndMillis();
long startMillis = chrono.add(period, endMillis, -1);
return new Interval(startMillis, endMillis, chrono);
}
|
java
|
public Interval withPeriodBeforeEnd(ReadablePeriod period) {
if (period == null) {
return withDurationBeforeEnd(null);
}
Chronology chrono = getChronology();
long endMillis = getEndMillis();
long startMillis = chrono.add(period, endMillis, -1);
return new Interval(startMillis, endMillis, chrono);
}
|
[
"public",
"Interval",
"withPeriodBeforeEnd",
"(",
"ReadablePeriod",
"period",
")",
"{",
"if",
"(",
"period",
"==",
"null",
")",
"{",
"return",
"withDurationBeforeEnd",
"(",
"null",
")",
";",
"}",
"Chronology",
"chrono",
"=",
"getChronology",
"(",
")",
";",
"long",
"endMillis",
"=",
"getEndMillis",
"(",
")",
";",
"long",
"startMillis",
"=",
"chrono",
".",
"add",
"(",
"period",
",",
"endMillis",
",",
"-",
"1",
")",
";",
"return",
"new",
"Interval",
"(",
"startMillis",
",",
"endMillis",
",",
"chrono",
")",
";",
"}"
] |
Creates a new interval with the specified period before the end instant.
@param period the period to subtract from the end to get the new start instant, null means zero
@return an interval with the end from this interval and a calculated start
@throws IllegalArgumentException if the period is negative
|
[
"Creates",
"a",
"new",
"interval",
"with",
"the",
"specified",
"period",
"before",
"the",
"end",
"instant",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/Interval.java#L552-L560
|
22,397
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/chrono/BasicMonthOfYearDateTimeField.java
|
BasicMonthOfYearDateTimeField.addWrapField
|
public long addWrapField(long instant, int months) {
return set(instant, FieldUtils.getWrappedValue(get(instant), months, MIN, iMax));
}
|
java
|
public long addWrapField(long instant, int months) {
return set(instant, FieldUtils.getWrappedValue(get(instant), months, MIN, iMax));
}
|
[
"public",
"long",
"addWrapField",
"(",
"long",
"instant",
",",
"int",
"months",
")",
"{",
"return",
"set",
"(",
"instant",
",",
"FieldUtils",
".",
"getWrappedValue",
"(",
"get",
"(",
"instant",
")",
",",
"months",
",",
"MIN",
",",
"iMax",
")",
")",
";",
"}"
] |
Add to the Month component of the specified time instant
wrapping around within that component if necessary.
@see org.joda.time.DateTimeField#addWrapField
@param instant the time instant in millis to update.
@param months the months to add (can be negative).
@return the updated time instant.
|
[
"Add",
"to",
"the",
"Month",
"component",
"of",
"the",
"specified",
"time",
"instant",
"wrapping",
"around",
"within",
"that",
"component",
"if",
"necessary",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/chrono/BasicMonthOfYearDateTimeField.java#L248-L250
|
22,398
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/field/LenientDateTimeField.java
|
LenientDateTimeField.set
|
public long set(long instant, int value) {
// lenient needs to handle time zone chronologies
// so we do the calculation using local milliseconds
long localInstant = iBase.getZone().convertUTCToLocal(instant);
long difference = FieldUtils.safeSubtract(value, get(instant));
localInstant = getType().getField(iBase.withUTC()).add(localInstant, difference);
return iBase.getZone().convertLocalToUTC(localInstant, false, instant);
}
|
java
|
public long set(long instant, int value) {
// lenient needs to handle time zone chronologies
// so we do the calculation using local milliseconds
long localInstant = iBase.getZone().convertUTCToLocal(instant);
long difference = FieldUtils.safeSubtract(value, get(instant));
localInstant = getType().getField(iBase.withUTC()).add(localInstant, difference);
return iBase.getZone().convertLocalToUTC(localInstant, false, instant);
}
|
[
"public",
"long",
"set",
"(",
"long",
"instant",
",",
"int",
"value",
")",
"{",
"// lenient needs to handle time zone chronologies",
"// so we do the calculation using local milliseconds",
"long",
"localInstant",
"=",
"iBase",
".",
"getZone",
"(",
")",
".",
"convertUTCToLocal",
"(",
"instant",
")",
";",
"long",
"difference",
"=",
"FieldUtils",
".",
"safeSubtract",
"(",
"value",
",",
"get",
"(",
"instant",
")",
")",
";",
"localInstant",
"=",
"getType",
"(",
")",
".",
"getField",
"(",
"iBase",
".",
"withUTC",
"(",
")",
")",
".",
"add",
"(",
"localInstant",
",",
"difference",
")",
";",
"return",
"iBase",
".",
"getZone",
"(",
")",
".",
"convertLocalToUTC",
"(",
"localInstant",
",",
"false",
",",
"instant",
")",
";",
"}"
] |
Set values which may be out of bounds by adding the difference between
the new value and the current value.
|
[
"Set",
"values",
"which",
"may",
"be",
"out",
"of",
"bounds",
"by",
"adding",
"the",
"difference",
"between",
"the",
"new",
"value",
"and",
"the",
"current",
"value",
"."
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/field/LenientDateTimeField.java#L69-L76
|
22,399
|
JodaOrg/joda-time
|
src/main/java/org/joda/time/tz/DefaultNameProvider.java
|
DefaultNameProvider.getShortName
|
public String getShortName(Locale locale, String id, String nameKey, boolean standardTime) {
String[] nameSet = getNameSet(locale, id, nameKey, standardTime);
return nameSet == null ? null : nameSet[0];
}
|
java
|
public String getShortName(Locale locale, String id, String nameKey, boolean standardTime) {
String[] nameSet = getNameSet(locale, id, nameKey, standardTime);
return nameSet == null ? null : nameSet[0];
}
|
[
"public",
"String",
"getShortName",
"(",
"Locale",
"locale",
",",
"String",
"id",
",",
"String",
"nameKey",
",",
"boolean",
"standardTime",
")",
"{",
"String",
"[",
"]",
"nameSet",
"=",
"getNameSet",
"(",
"locale",
",",
"id",
",",
"nameKey",
",",
"standardTime",
")",
";",
"return",
"nameSet",
"==",
"null",
"?",
"null",
":",
"nameSet",
"[",
"0",
"]",
";",
"}"
] |
handles changes to the nameKey better
|
[
"handles",
"changes",
"to",
"the",
"nameKey",
"better"
] |
bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42
|
https://github.com/JodaOrg/joda-time/blob/bd79f1c4245e79b3c2c56d7b04fde2a6e191fa42/src/main/java/org/joda/time/tz/DefaultNameProvider.java#L105-L108
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.