protected XMLGregorianCalendar getTrimmedCalendar() {
   if (trimmedCalendar == null) {
     trimmedCalendar = cloneXMLGregorianCalendar(calendar);
     BigDecimal fract = trimmedCalendar.getFractionalSecond();
     if (fract != null) {
       // TODO: replace following algorithm in JDK 1.5 with fract.stripTrailingZeros();
       String s = fract.toString();
       int i = s.length();
       while (i > 0 && s.charAt(i - 1) == '0') i--;
       if (i == 0) trimmedCalendar.setFractionalSecond(null);
       else if (i != s.length())
         trimmedCalendar.setFractionalSecond(new BigDecimal(s.substring(0, i)));
     }
   }
   return trimmedCalendar;
 }
Esempio n. 2
0
 public void setFractionalSecond(BigDecimal fractional) {
   calendar.setFractionalSecond(fractional);
 }