JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.chart
Class JCChartDateFormat

java.lang.Object
  |
  +--com.klg.jclass.chart.JCChartDateFormat

public class JCChartDateFormat
extends Object

JCChartDateFormat is a collection of methods and variables associated with time and date that are used throughout JCChart This class provides capabilities for writing internationalized code.


Constructor Summary
JCChartDateFormat()
           
 
Method Summary
protected  void addToUnit(Date d, long unit, int value)
          Adds a specified value to a particular unit in a Date instance.
protected  void calculateLargestTimeLabel(String pattern)
          Calculates and returns the largest time label based on a pattern
 int getDateStyle()
          Retrieve the current date style for the formatted time label.
protected static String getDefaultTimeFormat(double range)
          Internal method to return an appropriate time format for the provided range
protected  String getLargestLocaleTimeLabel()
          Calculates and returns the largest time label based on the default locale
protected  String getLargestTimeLabel(String pattern)
           
protected static Date getMaxTime()
          Returns the latest date that can be represented in Chart
protected static Date getMinTime()
          Returns the earliest date that can be represented in Chart
 int getTimeStyle()
          Retrieve the current time style for the formatted time label.
static void main(String[] args)
          For testing purposes only
protected  long niceInc(long incr, String pattern)
          Return the value in seconds of the smallest "nice" time increment greater than 'incr'.
protected  void roundTime(Date d, long unit, boolean adjust)
          Round the given time down/up to the given unit.
 void setDateStyle(int dateStyle)
          Set the date style for formatted time label
protected  void setLocale(Locale locale)
          Set the locale for formatting.
 void setTimeStyle(int timeStyle)
          Set the time style for formatted time label
protected  void setTimeZone(TimeZone timeZone)
          Set the time zone for formatting.
protected static long timeIncUnits(long inc)
           
protected  String timeLabel(Date date)
          Given an instance of Date, returns a formatted time label using the default locale, current dateStyle, and current timeStyle.
protected static String timeLabel(int style, Date date, Locale l)
          Given a format style and an instance of Date, returns a formatted time label using the default locale.
protected  String timeLabel(String pattern, Date date)
          Given a format pattern and an instance of Date, returns a formatted time label using the default locale
Time Format Syntax:
To specify the time format use a time pattern string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCChartDateFormat

public JCChartDateFormat()
Method Detail

setLocale

protected void setLocale(Locale locale)
Set the locale for formatting. This is called by JCAxis.setLocale().

Parameters:
locale - The new locale
See Also:
JCAxis.setLocale(java.util.Locale)

setTimeZone

protected void setTimeZone(TimeZone timeZone)
Set the time zone for formatting. This called by JCAxis.setTimeZone().

Parameters:
timeZone - The new time zone
See Also:
JCAxis.setTimeZone(java.util.TimeZone)

setDateStyle

public void setDateStyle(int dateStyle)
Set the date style for formatted time label

Parameters:
dateStyle - The new date style

getDateStyle

public int getDateStyle()
Retrieve the current date style for the formatted time label.

Returns:
The current date style.

setTimeStyle

public void setTimeStyle(int timeStyle)
Set the time style for formatted time label

Parameters:
timeStyle - The new time style

getTimeStyle

public int getTimeStyle()
Retrieve the current time style for the formatted time label.

Returns:
The current time style.

timeLabel

protected String timeLabel(Date date)
Given an instance of Date, returns a formatted time label using the default locale, current dateStyle, and current timeStyle.

Parameters:
date - the Date to be localized

timeLabel

protected static String timeLabel(int style,
                                  Date date,
                                  Locale l)
Given a format style and an instance of Date, returns a formatted time label using the default locale. The style of formatting can have on of the followig values: DateFormat.SHORT, DateFormat.MEDIUM, DateFormat.LONG or DateFormat.FULL

Parameters:
style - the format style to be used in date/time localization and can have one of the following values
date - the Date to be localized

timeLabel

protected String timeLabel(String pattern,
                           Date date)
Given a format pattern and an instance of Date, returns a formatted time label using the default locale
Time Format Syntax:
To specify the time format use a time pattern string. In this pattern, all ASCII letters are reserved as pattern letters, which are defined as the following:
Symbol Meaning Presentation Example
Gera designator(Text)AD
yyear(Number)1997
Mmonth in year(Text & Number) July & 07
dday in month(Number)10
hhour in am/pm (1~12)(Number)12
Hhour in day (0~23)(Number)0
mminute in hour(Number)30
ssecond in minute(Number)55
Smillisecond(Number)978
Eday in week(Text)Tuesday
Dday in year(Number)189
Fday of week in month(Number) 2 (2nd Wed in July)
wweek in year(Number)27
Wweek in month(Number)2
aam/pm marker(Text)PM
khour in day (1~24)(Number)24
Khour in am/pm (0~11)(Number)0
ztime zone(Text) Pacific Standard Time
'escape for text(delimiter)
''single quote(Literal)


getMinTime

protected static Date getMinTime()
Returns the earliest date that can be represented in Chart


getMaxTime

protected static Date getMaxTime()
Returns the latest date that can be represented in Chart


getLargestTimeLabel

protected String getLargestTimeLabel(String pattern)

calculateLargestTimeLabel

protected void calculateLargestTimeLabel(String pattern)
Calculates and returns the largest time label based on a pattern

Parameters:
pattern - Time label format

getLargestLocaleTimeLabel

protected String getLargestLocaleTimeLabel()
Calculates and returns the largest time label based on the default locale


roundTime

protected void roundTime(Date d,
                         long unit,
                         boolean adjust)
Round the given time down/up to the given unit. For example, if the unit is months, Feb 6 gets adjusted to Feb 1 00:00:00.

Parameters:
d - The date to be rounded.
unit - The unit of time (seconds, minutes, hours, days, etc)
adjust - If equal to 0, round down. If equal to 1, round up.

niceInc

protected long niceInc(long incr,
                       String pattern)
Return the value in seconds of the smallest "nice" time increment greater than 'incr'. The increment should also be of the same magnitude as indicated by 'format' (eg. a "%m" format should not return an increment less than MONTH)


timeIncUnits

protected static long timeIncUnits(long inc)

addToUnit

protected void addToUnit(Date d,
                         long unit,
                         int value)
Adds a specified value to a particular unit in a Date instance.

Parameters:
d - Date instance to be modified
unit - Time unit to which to add
value - Value to add to the specified unit

getDefaultTimeFormat

protected static String getDefaultTimeFormat(double range)
Internal method to return an appropriate time format for the provided range


main

public static void main(String[] args)
For testing purposes only

Parameters:
args - Command line arguments

Copyright © 2004 Quest Software Inc..
All rights reserved.