Java Doc for FastDateFormat.java in  » Library » Apache-common-lang » org » apache » commons » lang » time » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache common lang » org.apache.commons.lang.time 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.text.Format
      org.apache.commons.lang.time.FastDateFormat

FastDateFormat
public class FastDateFormat extends Format (Code)

FastDateFormat is a fast and thread-safe version of java.text.SimpleDateFormat .

This class can be used as a direct replacement to SimpleDateFormat in most formatting situations. This class is especially useful in multi-threaded server environments. SimpleDateFormat is not thread-safe in any JDK version, nor will it be as Sun have closed the bug/RFE.

Only formatting is supported, but all patterns are compatible with SimpleDateFormat (except time zones - see below).

Java 1.4 introduced a new pattern letter, 'Z', to represent time zones in RFC822 format (eg. +0800 or -1100). This pattern letter can be used here (on all JDK versions).

In addition, the pattern 'ZZ' has been made to represent ISO8601 full format time zones (eg. +08:00 or -11:00). This introduces a minor incompatibility with Java 1.4, but at a gain of useful functionality.


author:
   TeaTrove project
author:
   Brian S O'Neill
author:
   Sean Schofield
author:
   Gary Gregory
author:
   Stephen Colebourne
author:
   Nikolay Metchev
since:
   2.0
version:
   $Id: FastDateFormat.java 504349 2007-02-06 22:44:33Z bayard $


Field Summary
final public static  intFULL
     FULL locale dependent date or time style.
final public static  intLONG
     LONG locale dependent date or time style.
final public static  intMEDIUM
     MEDIUM locale dependent date or time style.
final public static  intSHORT
     SHORT locale dependent date or time style.

Constructor Summary
protected  FastDateFormat(String pattern, TimeZone timeZone, Locale locale)
    

Method Summary
protected  StringBufferapplyRules(Calendar calendar, StringBuffer buf)
    
public  booleanequals(Object obj)
    
public  StringBufferformat(Object obj, StringBuffer toAppendTo, FieldPosition pos)
    
public  Stringformat(long millis)
    
public  Stringformat(Date date)
    
public  Stringformat(Calendar calendar)
    
public  StringBufferformat(long millis, StringBuffer buf)
    
public  StringBufferformat(Date date, StringBuffer buf)
    
public  StringBufferformat(Calendar calendar, StringBuffer buf)
    
public static  FastDateFormatgetDateInstance(int style)
    
public static  FastDateFormatgetDateInstance(int style, Locale locale)
    
public static  FastDateFormatgetDateInstance(int style, TimeZone timeZone)
    
public static synchronized  FastDateFormatgetDateInstance(int style, TimeZone timeZone, Locale locale)
    
public static  FastDateFormatgetDateTimeInstance(int dateStyle, int timeStyle)
    
public static  FastDateFormatgetDateTimeInstance(int dateStyle, int timeStyle, Locale locale)
    
public static  FastDateFormatgetDateTimeInstance(int dateStyle, int timeStyle, TimeZone timeZone)
    
public static synchronized  FastDateFormatgetDateTimeInstance(int dateStyle, int timeStyle, TimeZone timeZone, Locale locale)
    
public static  FastDateFormatgetInstance()
    
public static  FastDateFormatgetInstance(String pattern)
    
public static  FastDateFormatgetInstance(String pattern, TimeZone timeZone)
    
public static  FastDateFormatgetInstance(String pattern, Locale locale)
    
public static synchronized  FastDateFormatgetInstance(String pattern, TimeZone timeZone, Locale locale)
    
public  LocalegetLocale()
    
public  intgetMaxLengthEstimate()
    
public  StringgetPattern()
    
public static  FastDateFormatgetTimeInstance(int style)
    
public static  FastDateFormatgetTimeInstance(int style, Locale locale)
    
public static  FastDateFormatgetTimeInstance(int style, TimeZone timeZone)
    
public static synchronized  FastDateFormatgetTimeInstance(int style, TimeZone timeZone, Locale locale)
    
public  TimeZonegetTimeZone()
    

Gets the time zone used by this formatter.

This zone is always used for Date formatting.

static synchronized  StringgetTimeZoneDisplay(TimeZone tz, boolean daylight, int style, Locale locale)
    
public  booleangetTimeZoneOverridesCalendar()
    
public  inthashCode()
    
protected  voidinit()
    
public  ObjectparseObject(String source, ParsePosition pos)
    
protected  ListparsePattern()
    
protected  StringparseToken(String pattern, int[] indexRef)
    
protected  NumberRuleselectNumberRule(int field, int padding)
    
public  StringtoString()
    

Field Detail
FULL
final public static int FULL(Code)
FULL locale dependent date or time style.



LONG
final public static int LONG(Code)
LONG locale dependent date or time style.



MEDIUM
final public static int MEDIUM(Code)
MEDIUM locale dependent date or time style.



SHORT
final public static int SHORT(Code)
SHORT locale dependent date or time style.




Constructor Detail
FastDateFormat
protected FastDateFormat(String pattern, TimeZone timeZone, Locale locale)(Code)

Constructs a new FastDateFormat.


Parameters:
  pattern - java.text.SimpleDateFormat compatiblepattern
Parameters:
  timeZone - time zone to use, null means usedefault for Date and value within forCalendar
Parameters:
  locale - locale, null means use systemdefault
throws:
  IllegalArgumentException - if pattern is invalid ornull




Method Detail
applyRules
protected StringBuffer applyRules(Calendar calendar, StringBuffer buf)(Code)

Performs the formatting by applying the rules to the specified calendar.


Parameters:
  calendar - the calendar to format
Parameters:
  buf - the buffer to format into the specified string buffer



equals
public boolean equals(Object obj)(Code)

Compares two objects for equality.


Parameters:
  obj - the object to compare to true if equal



format
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)(Code)

Formats a Date, Calendar or Long (milliseconds) object.


Parameters:
  obj - the object to format
Parameters:
  toAppendTo - the buffer to append to
Parameters:
  pos - the position - ignored the buffer passed in



format
public String format(long millis)(Code)

Formats a millisecond long value.


Parameters:
  millis - the millisecond value to format the formatted string
since:
   2.1



format
public String format(Date date)(Code)

Formats a Date object.


Parameters:
  date - the date to format the formatted string



format
public String format(Calendar calendar)(Code)

Formats a Calendar object.


Parameters:
  calendar - the calendar to format the formatted string



format
public StringBuffer format(long millis, StringBuffer buf)(Code)

Formats a milliseond long value into the supplied StringBuffer.


Parameters:
  millis - the millisecond value to format
Parameters:
  buf - the buffer to format into the specified string buffer
since:
   2.1



format
public StringBuffer format(Date date, StringBuffer buf)(Code)

Formats a Date object into the supplied StringBuffer.


Parameters:
  date - the date to format
Parameters:
  buf - the buffer to format into the specified string buffer



format
public StringBuffer format(Calendar calendar, StringBuffer buf)(Code)

Formats a Calendar object into the supplied StringBuffer.


Parameters:
  calendar - the calendar to format
Parameters:
  buf - the buffer to format into the specified string buffer



getDateInstance
public static FastDateFormat getDateInstance(int style)(Code)

Gets a date formatter instance using the specified style in the default time zone and locale.


Parameters:
  style - date style: FULL, LONG, MEDIUM, or SHORT a localized standard date formatter
throws:
  IllegalArgumentException - if the Locale has no datepattern defined
since:
   2.1



getDateInstance
public static FastDateFormat getDateInstance(int style, Locale locale)(Code)

Gets a date formatter instance using the specified style and locale in the default time zone.


Parameters:
  style - date style: FULL, LONG, MEDIUM, or SHORT
Parameters:
  locale - optional locale, overrides system locale a localized standard date formatter
throws:
  IllegalArgumentException - if the Locale has no datepattern defined
since:
   2.1



getDateInstance
public static FastDateFormat getDateInstance(int style, TimeZone timeZone)(Code)

Gets a date formatter instance using the specified style and time zone in the default locale.


Parameters:
  style - date style: FULL, LONG, MEDIUM, or SHORT
Parameters:
  timeZone - optional time zone, overrides time zone offormatted date a localized standard date formatter
throws:
  IllegalArgumentException - if the Locale has no datepattern defined
since:
   2.1



getDateInstance
public static synchronized FastDateFormat getDateInstance(int style, TimeZone timeZone, Locale locale)(Code)

Gets a date formatter instance using the specified style, time zone and locale.


Parameters:
  style - date style: FULL, LONG, MEDIUM, or SHORT
Parameters:
  timeZone - optional time zone, overrides time zone offormatted date
Parameters:
  locale - optional locale, overrides system locale a localized standard date formatter
throws:
  IllegalArgumentException - if the Locale has no datepattern defined



getDateTimeInstance
public static FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle)(Code)

Gets a date/time formatter instance using the specified style in the default time zone and locale.


Parameters:
  dateStyle - date style: FULL, LONG, MEDIUM, or SHORT
Parameters:
  timeStyle - time style: FULL, LONG, MEDIUM, or SHORT a localized standard date/time formatter
throws:
  IllegalArgumentException - if the Locale has no date/timepattern defined
since:
   2.1



getDateTimeInstance
public static FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale locale)(Code)

Gets a date/time formatter instance using the specified style and locale in the default time zone.


Parameters:
  dateStyle - date style: FULL, LONG, MEDIUM, or SHORT
Parameters:
  timeStyle - time style: FULL, LONG, MEDIUM, or SHORT
Parameters:
  locale - optional locale, overrides system locale a localized standard date/time formatter
throws:
  IllegalArgumentException - if the Locale has no date/timepattern defined
since:
   2.1



getDateTimeInstance
public static FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle, TimeZone timeZone)(Code)

Gets a date/time formatter instance using the specified style and time zone in the default locale.


Parameters:
  dateStyle - date style: FULL, LONG, MEDIUM, or SHORT
Parameters:
  timeStyle - time style: FULL, LONG, MEDIUM, or SHORT
Parameters:
  timeZone - optional time zone, overrides time zone offormatted date a localized standard date/time formatter
throws:
  IllegalArgumentException - if the Locale has no date/timepattern defined
since:
   2.1



getDateTimeInstance
public static synchronized FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle, TimeZone timeZone, Locale locale)(Code)

Gets a date/time formatter instance using the specified style, time zone and locale.


Parameters:
  dateStyle - date style: FULL, LONG, MEDIUM, or SHORT
Parameters:
  timeStyle - time style: FULL, LONG, MEDIUM, or SHORT
Parameters:
  timeZone - optional time zone, overrides time zone offormatted date
Parameters:
  locale - optional locale, overrides system locale a localized standard date/time formatter
throws:
  IllegalArgumentException - if the Locale has no date/timepattern defined



getInstance
public static FastDateFormat getInstance()(Code)

Gets a formatter instance using the default pattern in the default locale.

a date/time formatter



getInstance
public static FastDateFormat getInstance(String pattern)(Code)

Gets a formatter instance using the specified pattern in the default locale.


Parameters:
  pattern - java.text.SimpleDateFormat compatiblepattern a pattern based date/time formatter
throws:
  IllegalArgumentException - if pattern is invalid



getInstance
public static FastDateFormat getInstance(String pattern, TimeZone timeZone)(Code)

Gets a formatter instance using the specified pattern and time zone.


Parameters:
  pattern - java.text.SimpleDateFormat compatiblepattern
Parameters:
  timeZone - optional time zone, overrides time zone offormatted date a pattern based date/time formatter
throws:
  IllegalArgumentException - if pattern is invalid



getInstance
public static FastDateFormat getInstance(String pattern, Locale locale)(Code)

Gets a formatter instance using the specified pattern and locale.


Parameters:
  pattern - java.text.SimpleDateFormat compatiblepattern
Parameters:
  locale - optional locale, overrides system locale a pattern based date/time formatter
throws:
  IllegalArgumentException - if pattern is invalid



getInstance
public static synchronized FastDateFormat getInstance(String pattern, TimeZone timeZone, Locale locale)(Code)

Gets a formatter instance using the specified pattern, time zone and locale.


Parameters:
  pattern - java.text.SimpleDateFormat compatiblepattern
Parameters:
  timeZone - optional time zone, overrides time zone offormatted date
Parameters:
  locale - optional locale, overrides system locale a pattern based date/time formatter
throws:
  IllegalArgumentException - if pattern is invalidor null



getLocale
public Locale getLocale()(Code)

Gets the locale used by this formatter.

the locale



getMaxLengthEstimate
public int getMaxLengthEstimate()(Code)

Gets an estimate for the maximum string length that the formatter will produce.

The actual formatted length will almost always be less than or equal to this amount.

the maximum formatted length



getPattern
public String getPattern()(Code)

Gets the pattern used by this formatter.

the pattern, java.text.SimpleDateFormat compatible



getTimeInstance
public static FastDateFormat getTimeInstance(int style)(Code)

Gets a time formatter instance using the specified style in the default time zone and locale.


Parameters:
  style - time style: FULL, LONG, MEDIUM, or SHORT a localized standard time formatter
throws:
  IllegalArgumentException - if the Locale has no timepattern defined
since:
   2.1



getTimeInstance
public static FastDateFormat getTimeInstance(int style, Locale locale)(Code)

Gets a time formatter instance using the specified style and locale in the default time zone.


Parameters:
  style - time style: FULL, LONG, MEDIUM, or SHORT
Parameters:
  locale - optional locale, overrides system locale a localized standard time formatter
throws:
  IllegalArgumentException - if the Locale has no timepattern defined
since:
   2.1



getTimeInstance
public static FastDateFormat getTimeInstance(int style, TimeZone timeZone)(Code)

Gets a time formatter instance using the specified style and time zone in the default locale.


Parameters:
  style - time style: FULL, LONG, MEDIUM, or SHORT
Parameters:
  timeZone - optional time zone, overrides time zone offormatted time a localized standard time formatter
throws:
  IllegalArgumentException - if the Locale has no timepattern defined
since:
   2.1



getTimeInstance
public static synchronized FastDateFormat getTimeInstance(int style, TimeZone timeZone, Locale locale)(Code)

Gets a time formatter instance using the specified style, time zone and locale.


Parameters:
  style - time style: FULL, LONG, MEDIUM, or SHORT
Parameters:
  timeZone - optional time zone, overrides time zone offormatted time
Parameters:
  locale - optional locale, overrides system locale a localized standard time formatter
throws:
  IllegalArgumentException - if the Locale has no timepattern defined



getTimeZone
public TimeZone getTimeZone()(Code)

Gets the time zone used by this formatter.

This zone is always used for Date formatting. If a Calendar is passed in to be formatted, the time zone on that may be used depending on FastDateFormat.getTimeZoneOverridesCalendar() .

the time zone



getTimeZoneDisplay
static synchronized String getTimeZoneDisplay(TimeZone tz, boolean daylight, int style, Locale locale)(Code)

Gets the time zone display name, using a cache for performance.


Parameters:
  tz - the zone to query
Parameters:
  daylight - true if daylight savings
Parameters:
  style - the style to use TimeZone.LONGor TimeZone.SHORT
Parameters:
  locale - the locale to use the textual name of the time zone



getTimeZoneOverridesCalendar
public boolean getTimeZoneOverridesCalendar()(Code)

Returns true if the time zone of the calendar overrides the time zone of the formatter.

true if time zone of formatteroverridden for calendars



hashCode
public int hashCode()(Code)

Returns a hashcode compatible with equals.

a hashcode compatible with equals



init
protected void init()(Code)

Initializes the instance for first use.




parseObject
public Object parseObject(String source, ParsePosition pos)(Code)

Parsing is not supported.


Parameters:
  source - the string to parse
Parameters:
  pos - the parsing position null as not supported



parsePattern
protected List parsePattern()(Code)

Returns a list of Rules given a pattern.

a List of Rule objects
throws:
  IllegalArgumentException - if pattern is invalid



parseToken
protected String parseToken(String pattern, int[] indexRef)(Code)

Performs the parsing of tokens.


Parameters:
  pattern - the pattern
Parameters:
  indexRef - index references parsed token



selectNumberRule
protected NumberRule selectNumberRule(int field, int padding)(Code)

Gets an appropriate rule for the padding required.


Parameters:
  field - the field to get a rule for
Parameters:
  padding - the padding required a new rule with the correct padding



toString
public String toString()(Code)

Gets a debugging string version of this formatter.

a debugging string



Methods inherited from java.text.Format
public Object clone()(Code)(Java Doc)
final public String format(Object obj)(Code)(Java Doc)
abstract public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)(Code)(Java Doc)
public AttributedCharacterIterator formatToCharacterIterator(Object obj)(Code)(Java Doc)
abstract public Object parseObject(String source, ParsePosition pos)(Code)(Java Doc)
public Object parseObject(String source) throws ParseException(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.