*/
  @Override
  public String toString() {

    if (this == ZERO) {
      return "PT0S";
    } else {
      StringBuilder buf = new StringBuilder();
      buf.append('P');
      if (this.years != 0) {
        buf.append(this.years).append('Y');
      }
      if (this.months != 0) {
        buf.append(this.months).append('M');
      }
      if (this.days != 0) {
        buf.append(this.days).append('D');
      }
      if (this.nanos != 0) {
        buf.append('T');
        if (getHours() != 0) {
          buf.append(getHours()).append('H');
        }
        if (getMinutes() != 0) {
          buf.append(getMinutes()).append('M');
        }
        int secondPart = getSeconds();
        int nanoPart = getNanos();
        int secsNanosOr = secondPart | nanoPart;
        if (secsNanosOr != 0) { // if either non-zero
          if ((secsNanosOr & Integer.MIN_VALUE) != 0) { // if either less than zero
            buf.append('-');
            secondPart = Math.abs(secondPart);
            nanoPart = Math.abs(nanoPart);
          }
          buf.append(secondPart);
          if (nanoPart != 0) {
            int dotPos = buf.length();
            nanoPart += 1000000000;
            while (nanoPart % 10 == 0) {
              nanoPart /= 10;
            }
            buf.append(nanoPart);
            buf.setCharAt(dotPos, '.');
          }
          buf.append('S');
        }
      }
      return buf.toString();
    }
  }