类 ComparisonDateTool.Comparison

java.lang.Object
org.apache.velocity.tools.generic.ComparisonDateTool.Comparison
封闭类:
ComparisonDateTool

public class ComparisonDateTool.Comparison extends Object
  • 构造器详细资料

    • Comparison

      public Comparison(Calendar now, Calendar then, int type, int depth, boolean abbr, Locale loc)
      Comparison object constructor
      参数:
      now - The date to use as representative of "now"
      then - The secondary date
      type - comparison type
      depth - units depth
      abbr - whether to abbreviate units
      loc - locale to use
  • 方法详细资料

    • abbr

      public ComparisonDateTool.Comparison abbr(boolean abbr)
      Sets whether or not this comparison is to be rendered in abbreviated form or not. By default, it is not abbreviated.
      参数:
      abbr - flag value
      返回:
      new Comparison object
    • depth

      public ComparisonDateTool.Comparison depth(int depth)
      Set the maximum number of units to render for this comparison. By default, this is set to 1 unit.
      参数:
      depth - max units depth
      返回:
      new Comparison object
    • locale

      Sets the locale used to look up the textual portions of the rendering. This defaults to the Locale configured for this tool, if any. If no locale was configured, this defaults to the system default.
      参数:
      loc - locale to use
      返回:
      new Comparison object
    • getExactDifference

      protected final int[] getExactDifference()
      Internal helper returning a cached map of all exact bygone time units per field.
      返回:
      cached exact difference holder, as a calendar object
    • getYears

      public long getYears()
      Return the approximate number of years between the dates being compared, or the bygone number of years in exact mode.
      返回:
      years
    • getMonths

      public long getMonths()
      Return the approximate number of months between the dates being compared, or the bygone number of months after the bygone number of years in exact mode.
      返回:
      months
    • getWeeks

      public long getWeeks()
      Return the number of weeks between the dates being compared.
      返回:
      weeks
    • getDays

      public long getDays()
      Return the number of days between the dates being compared.
      返回:
      days
    • getHours

      public long getHours()
      Return the number of hours between the dates being compared.
      返回:
      hours
    • getMinutes

      public long getMinutes()
      Return the number of minutes between the dates being compared.
      返回:
      minutes
    • getSeconds

      public long getSeconds()
      Return the number of seconds between the dates being compared.
      返回:
      seconds
    • getMilliseconds

      public long getMilliseconds()
      Return the number of milliseconds between the dates being compared.
      返回:
      milliseconds
    • getFull

      Sets the depth(int depth) to which this comparison is rendered to the maximum number of time units available to the tool. By default, there are 8 units available, but the tool may be configured to "skip" any of the standard units, thus shortening the maximum depth.
      返回:
      new Comparison object
    • getDifference

      public ComparisonDateTool.Comparison getDifference()
      Sets this comparison to be rendered as a ComparisonDateTool.difference(java.lang.Object, java.lang.Object). This effectively means that the comparison will render as a period of time, without any suffix to describe the relative position of the dates being compared (e.g. "later" or "ago").
      返回:
      new Comparison object
    • getRelative

      public ComparisonDateTool.Comparison getRelative()
      Sets this comparison to be rendered as if it where generated using the ComparisonDateTool.whenIs(Object now, Object then) method. This effectively means that the comparison will render with a suffix to describe the relative position of the dates being compared (e.g. "later" or "ago").
      返回:
      new Comparison object
    • getExact

      public ComparisonDateTool.Comparison getExact()
      Sets this comparison to be rendered as if it where generated using the ComparisonDateTool.timespan(Object now, Object then) method. This effectively means that the comparison will render with a suffix to describe the relative position of the dates being compared (e.g. "later" or "ago").
      返回:
      new Comparison object
    • getAbbr

      This is equivalent to calling abbr(boolean abbr) with true as the argument, thus setting this comparison to be rendered in abbreviated form.
      返回:
      new Comparison object
    • toString

      protected String toString(long diff, int maxUnitDepth)
      Converts the specified positive duration of milliseconds into larger units up to the specified number of positive units, beginning with the largest positive unit. e.g. toString(181453, 3, false, null) will return "3 minutes 1 second 453 milliseconds", toString(181453, 2, false, null) will return "3 minutes 1 second", and toString(180000, 2, true, null) will return "3 min".
      参数:
      diff - milliseconds, or, in exact mode, time unit index
      maxUnitDepth - maximum unit depth
      返回:
      string representation of the difference
    • toString

      public String toString()
      Renders this comparison to a String.
      覆盖:
      toString 在类中 Object
      返回:
      string representation