示例#1
0
 /// <summary>
 /// Compares the value of two {@code FileTime} objects for order.
 /// </summary>
 /// <param name="other">
 ///          the other {@code FileTime} to be compared
 /// </param>
 /// <returns>  {@code 0} if this {@code FileTime} is equal to {@code other}, a
 ///          value less than 0 if this {@code FileTime} represents a time
 ///          that is before {@code other}, and a value greater than 0 if this
 ///          {@code FileTime} represents a time that is after {@code other} </returns>
 public int CompareTo(FileTime other)
 {
     // same granularity
     if (Unit != null && Unit == other.Unit)
     {
         return(Long.Compare(Value, other.Value));
     }
     else
     {
         // compare using instant representation when unit differs
         long secs      = ToInstant().EpochSecond;
         long secsOther = other.ToInstant().EpochSecond;
         int  cmp       = Long.Compare(secs, secsOther);
         if (cmp != 0)
         {
             return(cmp);
         }
         cmp = Long.Compare(ToInstant().Nano, other.ToInstant().Nano);
         if (cmp != 0)
         {
             return(cmp);
         }
         if (secs != MAX_SECOND && secs != MIN_SECOND)
         {
             return(0);
         }
         // if both this and other's Instant reps are MIN/MAX,
         // use daysSinceEpoch and nanosOfDays, which will not
         // saturate during calculation.
         long days      = ToDays();
         long daysOther = other.ToDays();
         if (days == daysOther)
         {
             return(Long.Compare(ToExcessNanos(days), other.ToExcessNanos(daysOther)));
         }
         return(Long.Compare(days, daysOther));
     }
 }
示例#2
0
 private static int Compare(long x, long y)
 {
     return(Long.Compare(x, y));
 }