/**
  * A limit chronology is only equal to a limit chronology with the same base chronology and
  * limits.
  *
  * @param obj the object to compare to
  * @return true if equal
  * @since 1.4
  */
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj instanceof LimitChronology == false) {
     return false;
   }
   LimitChronology chrono = (LimitChronology) obj;
   return getBase().equals(chrono.getBase())
       && FieldUtils.equals(getLowerLimit(), chrono.getLowerLimit())
       && FieldUtils.equals(getUpperLimit(), chrono.getUpperLimit());
 }
 /**
  * Gets the duration of the string using the standard type. This matches the toString() method of
  * ReadableDuration.
  *
  * @param object the String to convert, must not be null
  * @throws ClassCastException if the object is invalid
  */
 public long getDurationMillis(Object object) {
   // parse here because duration could be bigger than the int supported
   // by the period parser
   String original = (String) object;
   String str = original;
   int len = str.length();
   if (len >= 4
       && (str.charAt(0) == 'P' || str.charAt(0) == 'p')
       && (str.charAt(1) == 'T' || str.charAt(1) == 't')
       && (str.charAt(len - 1) == 'S' || str.charAt(len - 1) == 's')) {
     // ok
   } else {
     throw new IllegalArgumentException("Invalid format: \"" + original + '"');
   }
   str = str.substring(2, len - 1);
   int dot = -1;
   boolean negative = false;
   for (int i = 0; i < str.length(); i++) {
     if (str.charAt(i) >= '0' && str.charAt(i) <= '9') {
       // ok
     } else if (i == 0 && str.charAt(0) == '-') {
       // ok
       negative = true;
     } else if (i > (negative ? 1 : 0) && str.charAt(i) == '.' && dot == -1) {
       // ok
       dot = i;
     } else {
       throw new IllegalArgumentException("Invalid format: \"" + original + '"');
     }
   }
   long millis = 0, seconds = 0;
   int firstDigit = negative ? 1 : 0;
   if (dot > 0) {
     seconds = Long.parseLong(str.substring(firstDigit, dot));
     str = str.substring(dot + 1);
     if (str.length() != 3) {
       str = (str + "000").substring(0, 3);
     }
     millis = Integer.parseInt(str);
   } else if (negative) {
     seconds = Long.parseLong(str.substring(firstDigit, str.length()));
   } else {
     seconds = Long.parseLong(str);
   }
   if (negative) {
     return FieldUtils.safeAdd(FieldUtils.safeMultiply(-seconds, 1000), -millis);
   } else {
     return FieldUtils.safeAdd(FieldUtils.safeMultiply(seconds, 1000), millis);
   }
 }