199 } else { 200 // compare using days/nanos representation when unit differs 201 return asDaysAndNanos().compareTo(other.asDaysAndNanos()); 202 } 203 } 204 205 /** 206 * Returns the string representation of this {@code FileTime}. The string 207 * is returned in the <a 208 * href="http://www.w3.org/TR/NOTE-datetime">ISO 8601</a> format: 209 * <pre> 210 * YYYY-MM-DDThh:mm:ss[.s+]Z 211 * </pre> 212 * where "{@code [.s+]}" represents a dot followed by one of more digits 213 * for the decimal fraction of a second. It is only present when the decimal 214 * fraction of a second is not zero. For example, {@code 215 * FileTime.fromMillis(1234567890000L).toString()} yields {@code 216 * "2009-02-13T23:31:30Z"}, and {@code FileTime.fromMillis(1234567890123L).toString()} 217 * yields {@code "2009-02-13T23:31:30.123Z"}. 218 * 219 * <p> A {@code FileTime} is primarly intended to represent the value of a 220 * file's time stamp. Where used to represent <i>extreme values</i>, where 221 * the year is less than "{@code 0001}" or greater than "{@code 9999}" then 222 * the year may be expanded to more than four digits and may be 223 * negative-signed. If more than four digits then leading zeros are not 224 * present. The year before "{@code 0001}" is "{@code -0001}". 225 * 226 * @return the string representation of this file time 227 */ 228 @Override 229 public String toString() { 230 String v = valueAsString; 231 if (v == null) { 232 // overflow saturates to Long.MIN_VALUE or Long.MAX_VALUE so this 233 // limits the range: 234 // [-292275056-05-16T16:47:04.192Z,292278994-08-17T07:12:55.807Z] 235 long ms = toMillis(); 236 237 // nothing to do when seconds/minutes/hours/days 238 String fractionAsString = ""; 239 if (unit.compareTo(TimeUnit.SECONDS) < 0) { 240 long fraction = asDaysAndNanos().fractionOfSecondInNanos(); 241 if (fraction != 0L) { 242 // fraction must be positive 243 if (fraction < 0L) { 244 final long MAX_FRACTION_PLUS_1 = 1000L * 1000L * 1000L; | 199 } else { 200 // compare using days/nanos representation when unit differs 201 return asDaysAndNanos().compareTo(other.asDaysAndNanos()); 202 } 203 } 204 205 /** 206 * Returns the string representation of this {@code FileTime}. The string 207 * is returned in the <a 208 * href="http://www.w3.org/TR/NOTE-datetime">ISO 8601</a> format: 209 * <pre> 210 * YYYY-MM-DDThh:mm:ss[.s+]Z 211 * </pre> 212 * where "{@code [.s+]}" represents a dot followed by one of more digits 213 * for the decimal fraction of a second. It is only present when the decimal 214 * fraction of a second is not zero. For example, {@code 215 * FileTime.fromMillis(1234567890000L).toString()} yields {@code 216 * "2009-02-13T23:31:30Z"}, and {@code FileTime.fromMillis(1234567890123L).toString()} 217 * yields {@code "2009-02-13T23:31:30.123Z"}. 218 * 219 * <p> A {@code FileTime} is primarily intended to represent the value of a 220 * file's time stamp. Where used to represent <i>extreme values</i>, where 221 * the year is less than "{@code 0001}" or greater than "{@code 9999}" then 222 * this method deviates from ISO 8601 in the same manner as the 223 * <a href="http://www.w3.org/TR/xmlschema-2/#deviantformats">XML Schema 224 * language</a>. That is, the year may be expanded to more than four digits 225 * and may be negative-signed. If more than four digits then leading zeros 226 * are not present. The year before "{@code 0001}" is "{@code -0001}". 227 * 228 * @return the string representation of this file time 229 */ 230 @Override 231 public String toString() { 232 String v = valueAsString; 233 if (v == null) { 234 // overflow saturates to Long.MIN_VALUE or Long.MAX_VALUE so this 235 // limits the range: 236 // [-292275056-05-16T16:47:04.192Z,292278994-08-17T07:12:55.807Z] 237 long ms = toMillis(); 238 239 // nothing to do when seconds/minutes/hours/days 240 String fractionAsString = ""; 241 if (unit.compareTo(TimeUnit.SECONDS) < 0) { 242 long fraction = asDaysAndNanos().fractionOfSecondInNanos(); 243 if (fraction != 0L) { 244 // fraction must be positive 245 if (fraction < 0L) { 246 final long MAX_FRACTION_PLUS_1 = 1000L * 1000L * 1000L; |