diff --git a/src/main/java/org/joda/time/Period.java b/src/main/java/org/joda/time/Period.java index 9726aa8a2..8014d062d 100644 --- a/src/main/java/org/joda/time/Period.java +++ b/src/main/java/org/joda/time/Period.java @@ -1650,7 +1650,7 @@ public Period normalizedStandard(PeriodType type) { if (type.isSupported(DurationFieldType.YEARS_TYPE)) { int normalizedYears = FieldUtils.safeToInt(totalMonths / 12); result = result.withYears(normalizedYears); - totalMonths = totalMonths - (normalizedYears * 12); + totalMonths = totalMonths - (normalizedYears * 12L); } if (type.isSupported(DurationFieldType.MONTHS_TYPE)) { int normalizedMonths = FieldUtils.safeToInt(totalMonths); diff --git a/src/main/java/org/joda/time/chrono/BasicChronology.java b/src/main/java/org/joda/time/chrono/BasicChronology.java index d9208b5ef..b1ae7345f 100644 --- a/src/main/java/org/joda/time/chrono/BasicChronology.java +++ b/src/main/java/org/joda/time/chrono/BasicChronology.java @@ -177,9 +177,9 @@ public long getDateTimeMillis( FieldUtils.verifyValueBounds(DateTimeFieldType.minuteOfHour(), minuteOfHour, 0, 59); FieldUtils.verifyValueBounds(DateTimeFieldType.secondOfMinute(), secondOfMinute, 0, 59); FieldUtils.verifyValueBounds(DateTimeFieldType.millisOfSecond(), millisOfSecond, 0, 999); - long millisOfDay = hourOfDay * DateTimeConstants.MILLIS_PER_HOUR - + minuteOfHour * DateTimeConstants.MILLIS_PER_MINUTE - + secondOfMinute * DateTimeConstants.MILLIS_PER_SECOND + long millisOfDay = (long) hourOfDay * DateTimeConstants.MILLIS_PER_HOUR + + (long) minuteOfHour * DateTimeConstants.MILLIS_PER_MINUTE + + (long) secondOfMinute * DateTimeConstants.MILLIS_PER_SECOND + millisOfSecond; return getDateTimeMillis0(year, monthOfYear, dayOfMonth, (int) millisOfDay); } diff --git a/src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java b/src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java index b3fe7a3de..b3273eea9 100644 --- a/src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java +++ b/src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java @@ -2382,7 +2382,7 @@ public int parseInto(DateTimeParserBucket bucket, CharSequence text, int positio prefix = text.subSequence(pos, i + 1).toString(); pos += prefix.length(); String prefixLookup = prefix; - if (i < textLen) { + if (i < textLen - 1) { prefixLookup += text.charAt(i + 1); } suffixSet = GROUPED_IDS.get(prefixLookup); @@ -2631,7 +2631,7 @@ public int parseInto(DateTimeParserBucket bucket, CharSequence text, int positio bucket.restoreState(originalState); } - if (bestValidPos > position || (bestValidPos == position && isOptional)) { + if (bestValidPos > position || (bestValidPos == position && isOptional)) { // LGTM ignore // Restore the state to the best valid parse. if (bestValidState != null) { bucket.restoreState(bestValidState); diff --git a/src/main/java/org/joda/time/format/PeriodFormatterBuilder.java b/src/main/java/org/joda/time/format/PeriodFormatterBuilder.java index 78d62a819..00bdb2c15 100644 --- a/src/main/java/org/joda/time/format/PeriodFormatterBuilder.java +++ b/src/main/java/org/joda/time/format/PeriodFormatterBuilder.java @@ -1775,7 +1775,7 @@ long getFieldValue(ReadablePeriod period) { if (isZero(period) && iFieldFormatters[iFieldType] == this) { int i = Math.min(iFieldType, 8); // line split out for IBM JDK i--; // see bug 1660490 - for (; i >= 0 && i <= MAX_FIELD; i--) { + for (; i >= 0; i--) { if (isSupported(type, i) && iFieldFormatters[i] != null) { return Long.MAX_VALUE; } diff --git a/src/main/java/org/joda/time/tz/ZoneInfoCompiler.java b/src/main/java/org/joda/time/tz/ZoneInfoCompiler.java index 36e11ceb4..8bcd9127d 100644 --- a/src/main/java/org/joda/time/tz/ZoneInfoCompiler.java +++ b/src/main/java/org/joda/time/tz/ZoneInfoCompiler.java @@ -168,7 +168,7 @@ static void writeZoneInfoMap(DataOutputStream dout, Map zi Short index = Short.valueOf(count); idToIndex.put(id, index); indexToId.put(index, id); - if (++count == 0) { + if (++count == Integer.MAX_VALUE) { throw new InternalError("Too many time zone ids"); } } @@ -177,7 +177,7 @@ static void writeZoneInfoMap(DataOutputStream dout, Map zi Short index = Short.valueOf(count); idToIndex.put(id, index); indexToId.put(index, id); - if (++count == 0) { + if (++count == Integer.MAX_VALUE) { throw new InternalError("Too many time zone ids"); } }