public class

RelativeDateFormat

extends DateFormat
java.lang.Object
   ↳ java.text.Format
     ↳ java.text.DateFormat
       ↳ org.jfree.chart.util.RelativeDateFormat

Class Overview

A formatter that formats dates to show the elapsed time relative to some base date.

Summary

[Expand]
Inherited Constants
From class java.text.DateFormat
[Expand]
Inherited Fields
From class java.text.DateFormat
Public Constructors
RelativeDateFormat()
Creates a new instance with base milliseconds set to zero.
RelativeDateFormat(Date time)
Creates a new instance.
RelativeDateFormat(long baseMillis)
Creates a new instance.
Public Methods
Object clone()
Returns a clone of this instance.
boolean equals(Object obj)
Tests this formatter for equality with an arbitrary object.
StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)
Formats the given date as the amount of elapsed time (relative to the base date specified in the constructor).
long getBaseMillis()
Returns the base date/time used to calculate the elapsed time for display.
String getDaySuffix()
Returns the string that is appended to the day count.
String getHourSuffix()
Returns the string that is appended to the hour count.
String getMinuteSuffix()
Returns the string that is appended to the minute count.
String getPositivePrefix()
Returns the string that is prepended to the format if the relative time is positive.
String getSecondSuffix()
Returns the string that is appended to the second count.
boolean getShowZeroDays()
Returns the flag that controls whether or not zero day counts are shown in the formatted output.
boolean getShowZeroHours()
Returns the flag that controls whether or not zero hour counts are shown in the formatted output.
int hashCode()
Returns a hash code for this instance.
static void main(String[] args)
Some test code.
Date parse(String source, ParsePosition pos)
Parses the given string (not implemented).
void setBaseMillis(long baseMillis)
Sets the base date/time used to calculate the elapsed time for display.
void setDayFormatter(NumberFormat formatter)
Sets the formatter for the days.
void setDaySuffix(String suffix)
Sets the string that is appended to the day count.
void setHourFormatter(NumberFormat formatter)
Sets the formatter for the hours.
void setHourSuffix(String suffix)
Sets the string that is appended to the hour count.
void setMinuteFormatter(NumberFormat formatter)
Sets the formatter for the minutes.
void setMinuteSuffix(String suffix)
Sets the string that is appended to the minute count.
void setPositivePrefix(String prefix)
Sets the string that is prepended to the format if the relative time is positive.
void setSecondFormatter(NumberFormat formatter)
Sets the formatter for the seconds and milliseconds.
void setSecondSuffix(String suffix)
Sets the string that is appended to the second count.
void setShowZeroDays(boolean show)
Sets the flag that controls whether or not zero day counts are shown in the formatted output.
void setShowZeroHours(boolean show)
Sets the flag that controls whether or not zero hour counts are shown in the formatted output.
[Expand]
Inherited Methods
From class java.text.DateFormat
From class java.text.Format
From class java.lang.Object

Public Constructors

public RelativeDateFormat ()

Creates a new instance with base milliseconds set to zero.

public RelativeDateFormat (Date time)

Creates a new instance.

Parameters
time the date/time (null not permitted).

public RelativeDateFormat (long baseMillis)

Creates a new instance.

Parameters
baseMillis the time zone (null not permitted).

Public Methods

public Object clone ()

Returns a clone of this instance.

Returns
  • A clone.

public boolean equals (Object obj)

Tests this formatter for equality with an arbitrary object.

Parameters
obj the object (null permitted).
Returns
  • A boolean.

public StringBuffer format (Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)

Formats the given date as the amount of elapsed time (relative to the base date specified in the constructor).

Parameters
date the date.
toAppendTo the string buffer.
fieldPosition the field position.
Returns
  • The formatted date.

public long getBaseMillis ()

Returns the base date/time used to calculate the elapsed time for display.

Returns
  • The base date/time in milliseconds since 1-Jan-1970.

public String getDaySuffix ()

Returns the string that is appended to the day count.

Returns
  • The string.

public String getHourSuffix ()

Returns the string that is appended to the hour count.

Returns
  • The string.

public String getMinuteSuffix ()

Returns the string that is appended to the minute count.

Returns
  • The string.

public String getPositivePrefix ()

Returns the string that is prepended to the format if the relative time is positive.

Returns
  • The string (never null).

public String getSecondSuffix ()

Returns the string that is appended to the second count.

Returns
  • The string.

public boolean getShowZeroDays ()

Returns the flag that controls whether or not zero day counts are shown in the formatted output.

Returns
  • The flag.

public boolean getShowZeroHours ()

Returns the flag that controls whether or not zero hour counts are shown in the formatted output.

Returns
  • The flag.

public int hashCode ()

Returns a hash code for this instance.

Returns
  • A hash code.

public static void main (String[] args)

Some test code.

Parameters
args ignored.

public Date parse (String source, ParsePosition pos)

Parses the given string (not implemented).

Parameters
source the date string.
pos the parse position.
Returns
  • null, as this method has not been implemented.

public void setBaseMillis (long baseMillis)

Sets the base date/time used to calculate the elapsed time for display. This should be specified in milliseconds using the same encoding as java.util.Date.

Parameters
baseMillis the base date/time in milliseconds.
See Also

public void setDayFormatter (NumberFormat formatter)

Sets the formatter for the days.

Parameters
formatter the formatter (null not permitted).

public void setDaySuffix (String suffix)

Sets the string that is appended to the day count.

Parameters
suffix the suffix (null not permitted).
See Also

public void setHourFormatter (NumberFormat formatter)

Sets the formatter for the hours.

Parameters
formatter the formatter (null not permitted).

public void setHourSuffix (String suffix)

Sets the string that is appended to the hour count.

Parameters
suffix the suffix (null not permitted).
See Also

public void setMinuteFormatter (NumberFormat formatter)

Sets the formatter for the minutes.

Parameters
formatter the formatter (null not permitted).

public void setMinuteSuffix (String suffix)

Sets the string that is appended to the minute count.

Parameters
suffix the suffix (null not permitted).

public void setPositivePrefix (String prefix)

Sets the string that is prepended to the format if the relative time is positive.

Parameters
prefix the prefix (null not permitted).

public void setSecondFormatter (NumberFormat formatter)

Sets the formatter for the seconds and milliseconds.

Parameters
formatter the formatter (null not permitted).

public void setSecondSuffix (String suffix)

Sets the string that is appended to the second count.

Parameters
suffix the suffix (null not permitted).

public void setShowZeroDays (boolean show)

Sets the flag that controls whether or not zero day counts are shown in the formatted output.

Parameters
show the flag.

public void setShowZeroHours (boolean show)

Sets the flag that controls whether or not zero hour counts are shown in the formatted output.

Parameters
show the flag.