class DurationValue extends ScalarValue implements TemporalAmount, Comparable<DurationValue> {

    @Override
    public String prettyPrint()
    {
        if ( this == ZERO )
        {
            return "PT0S"; // no need to allocate a string builder if we know the result
        }
        StringBuilder str = new StringBuilder().append( "P" );
        append( str, months / 12, 'Y' );
        append( str, months % 12, 'M' );
        append( str, days, 'D' );
        if ( seconds != 0 || nanos != 0 )
        {
            boolean negative = seconds < 0;
            long s = seconds;
            int n = nanos;
            if ( negative && nanos != 0 )
            {
                s++;
                n -= NANOS_PER_SECOND;
            }
            str.append( 'T' );
            append( str, s / 3600, 'H' );
            s %= 3600;
            append( str, s / 60, 'M' );
            s %= 60;
            if ( s != 0 )
            {
                if ( negative && s >= 0 && n != 0 )
                {
                    str.append( '-' );
                }
                str.append( s );
                if ( n != 0 )
                {
                    nanos( str, n );
                }
                str.append( 'S' );
            }
            else if ( n != 0 )
            {
                if ( negative )
                {
                    str.append( '-' );
                }
                str.append( '0' );
                nanos( str, n );
                str.append( 'S' );
            }
        }
        if ( str.length() == 1 )
        { // this was all zeros (but not ZERO for some reason), ensure well formed output:
            str.append( "T0S" );
        }
        return str.toString();
    }

    private  DurationValue( long months, long days, long seconds, long nanos );

}