类 TimeSpan

java.lang.Object
cn.vorbote.core.time.TimeSpan

public final class TimeSpan extends Object
Represents a time interval. We use this class to show diffs from 2 DateTime instances.
作者:
vorbote
  • 嵌套类概要

    嵌套类
    修饰符和类型
    说明
    static class 
    Inner class Builder of TimeSpan.
  • 构造器概要

    构造器
    构造器
    说明
    No-args constructor, you can use this to build a TimeSpan with 0 days, 0 hours, 0 minutes and 0 seconds.
    TimeSpan(int totalSeconds)
    This constructor will build a TimeSpan with specific total seconds.
    TimeSpan(int days, int hours, int minutes, int seconds)
    This constructor will build a TimeSpan with specific data.
  • 方法概要

    修饰符和类型
    方法
    说明
    addDays(int days)
    Add days to this TimeSpan.
    Note: This method support chain call.
    addHours(int hours)
    Add hours to this TimeSpan.
    Note: This method support chain call.
    addMinutes(int minutes)
    Add minutes to this TimeSpan.
    Note: This method support chain call.
    addSeconds(int seconds)
    Add seconds to this TimeSpan.
    Note: This method support chain call.
    Generate a builder of TimeSpan.
    boolean
    Check that the given Object instance is equal to this instance.
    int
    Get the number of days between two times.
    int
    Get the number of hours between two times.
    int
    Get the number of minutes between two times.
    int
    Get the number of seconds between two times.
    long
    Get total seconds.
    int
     
    void
    setTotalSeconds(long totalSeconds)
    Set total seconds.
     
    double
    Get the total hours in this TimeSpan.
    long
    Get the total seconds in this TimeSpan.
    totalSeconds(long totalSeconds)
     

    从类继承的方法 java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 构造器详细资料

    • TimeSpan

      public TimeSpan()
      No-args constructor, you can use this to build a TimeSpan with 0 days, 0 hours, 0 minutes and 0 seconds.
    • TimeSpan

      public TimeSpan(int totalSeconds)
      This constructor will build a TimeSpan with specific total seconds.
      参数:
      totalSeconds - The total seconds of this TimeSpan
    • TimeSpan

      public TimeSpan(int days, int hours, int minutes, int seconds)
      This constructor will build a TimeSpan with specific data.
      参数:
      days - The days of this TimeSpan.
      hours - The hours of this TimeSpan.
      minutes - The minutes of this TimeSpan.
      seconds - The seconds of this TimeSpan.
  • 方法详细资料

    • getTotalSeconds

      public long getTotalSeconds()
      Get total seconds.
      返回:
      Total seconds.
    • setTotalSeconds

      public void setTotalSeconds(long totalSeconds)
      Set total seconds.
      参数:
      totalSeconds - Total seconds.
    • getDays

      public int getDays()
      Get the number of days between two times.
      返回:
      The number of days between two times.
    • getHours

      public int getHours()
      Get the number of hours between two times.
      返回:
      The number of hours between two times.
    • getMinutes

      public int getMinutes()
      Get the number of minutes between two times.
      返回:
      The number of minutes between two times.
    • getSeconds

      public int getSeconds()
      Get the number of seconds between two times.
      返回:
      The number of seconds between two times.
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object
    • totalSeconds

      public long totalSeconds()
      Get the total seconds in this TimeSpan.
      返回:
      The total seconds in this TimeSpan.
    • totalSeconds

      public TimeSpan totalSeconds(long totalSeconds)
    • totalHours

      public double totalHours()
      Get the total hours in this TimeSpan.
      返回:
      The total milliseconds in this TimeSpan.
      另请参阅:
    • equals

      public boolean equals(Object o)
      Check that the given Object instance is equal to this instance.
      覆盖:
      equals 在类中 Object
      参数:
      o - The given Object instance,
      返回:
      Value true will be returned when the Object o is equal to this instance.
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object
    • builder

      public static TimeSpan.Builder builder()
      Generate a builder of TimeSpan.
      返回:
      A builder of TimeSpan.
    • addSeconds

      public TimeSpan addSeconds(int seconds)
      Add seconds to this TimeSpan.
      Note: This method support chain call.
      参数:
      seconds - Seconds need to be added to this TimeSpan.
      返回:
      The TimeSpan instance itself.
    • addMinutes

      public TimeSpan addMinutes(int minutes)
      Add minutes to this TimeSpan.
      Note: This method support chain call.
      参数:
      minutes - Minutes need to be added to this TimeSpan.
      返回:
      The TimeSpan instance itself.
    • addHours

      public TimeSpan addHours(int hours)
      Add hours to this TimeSpan.
      Note: This method support chain call.
      参数:
      hours - Hours need to be added to this TimeSpan.
      返回:
      The TimeSpan instance itself.
    • addDays

      public TimeSpan addDays(int days)
      Add days to this TimeSpan.
      Note: This method support chain call.
      参数:
      days - Days need to be added to this TimeSpan.
      返回:
      The TimeSpan instance itself.