Java Doc for DateTimeFormat.java in  » Ajax » GWT » com » google » gwt » i18n » client » 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 » Ajax » GWT » com.google.gwt.i18n.client 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.google.gwt.i18n.client.DateTimeFormat

DateTimeFormat
public class DateTimeFormat (Code)
Formats and parses dates and times using locale-sensitive patterns.

Patterns

Symbol Meaning Presentation Example
G era designator Text AD
y year Number 1996
M month in year Text or Number July (or) 07
d day in month Number 10
h hour in am/pm (1-12) Number 12
H hour in day (0-23) Number 0
m minute in hour Number 30
s second in minute Number 55
S fractional second Number 978
E day of week Text Tuesday
a am/pm marker Text PM
k hour in day (1-24) Number 24
K hour in am/pm (0-11) Number 0
z time zone Text Pacific Standard Time
Z time zone (RFC 822) Number -0800
v time zone (generic) Text Pacific Time
' escape for text Delimiter 'Date='
'' single quote Literal 'o''clock'

The number of pattern letters influences the format, as follows:

Text
if 4 or more, then use the full form; if less than 4, use short or abbreviated form if it exists (e.g., "EEEE" produces "Monday", "EEE" produces "Mon")
Number
the minimum number of digits. Shorter numbers are zero-padded to this amount (e.g. if "m" produces "6", "mm" produces "06"). Year is handled specially; that is, if the count of 'y' is 2, the Year will be truncated to 2 digits. (e.g., if "yyyy" produces "1997", "yy" produces "97".) Unlike other fields, fractional seconds are padded on the right with zero.
Text or Number
3 or more, use text, otherwise use number. (e.g. "M" produces "1", "MM" produces "01", "MMM" produces "Jan", and "MMMM" produces "January".

Any characters in the pattern that are not in the ranges of ['a'..'z'] and ['A'..'Z'] will be treated as quoted text. For instance, characters like ':', '.', ' ' (space), '#' and '@' will appear in the resulting time text even they are not embraced within single quotes.

Parsing Dates and Times

This implementation could parse partial date/time. Current date will be used to fill in the unavailable date part. 00:00:00 will be used to fill in the time part.

As with formatting (described above), the count of pattern letters determine the parsing behavior.

Text
4 or more pattern letters--use full form, less than 4--use short or abbreviated form if one exists. In parsing, we will always try long format, then short.
Number
the minimum number of digits.
Text or Number
3 or more characters means use text, otherwise use number

Although the current pattern specification doesn't not specify behavior for all letters, it may in the future. It is strongly discouraged to used unspecified letters as literal text without being surrounded by quotes.

Examples

Pattern Formatted Text
"yyyy.MM.dd G 'at' HH:mm:ss vvvv" 1996.07.10 AD at 15:08:56 Pacific Time
"EEE, MMM d, ''yy" Wed, July 10, '96
"h:mm a" 12:08 PM
"hh 'o''clock' a, zzzz" 12 o'clock PM, Pacific Daylight Time
"K:mm a, vvv" 0:00 PM, PT
"yyyyy.MMMMM.dd GGG hh:mm aaa" 01996.July.10 AD 12:08 PM

Additional Parsing Considerations

When parsing a date string using the abbreviated year pattern ("yy"), the parser must interpret the abbreviated year relative to some century. It does this by adjusting dates to be within 80 years before and 20 years after the time the parser instance is created. For example, using a pattern of "MM/dd/yy" and a DateTimeFormat object created on Jan 1, 1997, the string "01/11/12" would be interpreted as Jan 11, 2012 while the string "05/04/64" would be interpreted as May 4, 1964. During parsing, only strings consisting of exactly two digits, as defined by java.lang.Character.isDigit(char) , will be parsed into the default century. If the year pattern does not have exactly two 'y' characters, the year is interpreted literally, regardless of the number of digits. For example, using the pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D.

When numeric fields abut one another directly, with no intervening delimiter characters, they constitute a run of abutting numeric fields. Such runs are parsed specially. For example, the format "HHmmss" parses the input text "123456" to 12:34:56, parses the input text "12345" to 1:23:45, and fails to parse "1234". In other words, the leftmost field of the run is flexible, while the others keep a fixed width. If the parse fails anywhere in the run, then the leftmost field is shortened by one character, and the entire run is parsed again. This is repeated until either the parse succeeds or the leftmost field is one character in length. If the parse still fails at that point, the parse of the run fails.

In the current implementation, timezone parsing only supports GMT:hhmm, GMT:+hhmm, and GMT:-hhmm.




Constructor Summary
protected  DateTimeFormat(String pattern)
     Constructs a format object using the specified pattern and the date time constants for the default locale.
protected  DateTimeFormat(String pattern, DateTimeConstants dateTimeConstants)
     Constructs a format object using the specified pattern and user-supplied date time constants.

Method Summary
public  Stringformat(Date date)
     Format a date object.
public static  DateTimeFormatgetFormat(String pattern)
     Returns a format object using the specified pattern and the date time constants for the default locale.
public static  DateTimeFormatgetFullDateFormat()
    
public static  DateTimeFormatgetFullDateTimeFormat()
    
public static  DateTimeFormatgetFullTimeFormat()
    
public static  DateTimeFormatgetLongDateFormat()
    
public static  DateTimeFormatgetLongDateTimeFormat()
    
public static  DateTimeFormatgetLongTimeFormat()
    
public static  DateTimeFormatgetMediumDateFormat()
    
public static  DateTimeFormatgetMediumDateTimeFormat()
    
public static  DateTimeFormatgetMediumTimeFormat()
    
public  StringgetPattern()
    
public static  DateTimeFormatgetShortDateFormat()
    
public static  DateTimeFormatgetShortDateTimeFormat()
    
public static  DateTimeFormatgetShortTimeFormat()
    
public  Dateparse(String text)
     Parses text to produce a Date value.
public  intparse(String text, int start, Date date)
     This method parses the input string, fill its value into a Date .


Constructor Detail
DateTimeFormat
protected DateTimeFormat(String pattern)(Code)
Constructs a format object using the specified pattern and the date time constants for the default locale.
Parameters:
  pattern - string pattern specification



DateTimeFormat
protected DateTimeFormat(String pattern, DateTimeConstants dateTimeConstants)(Code)
Constructs a format object using the specified pattern and user-supplied date time constants.
Parameters:
  pattern - string pattern specification
Parameters:
  dateTimeConstants - locale specific symbol collection




Method Detail
format
public String format(Date date)(Code)
Format a date object.
Parameters:
  date - the date object being formatted formatted date representation



getFormat
public static DateTimeFormat getFormat(String pattern)(Code)
Returns a format object using the specified pattern and the date time constants for the default locale. If you need to format or parse repeatedly using the same pattern, it is highly recommended that you cache the returned DateTimeFormat object and reuse it rather than calling this method repeatedly.
Parameters:
  pattern - string to specify how the date should be formatted a DateTimeFormat object that can be used for formator parse date/time values matching the specified pattern
throws:
  IllegalArgumentException - if the specified pattern could not beparsed



getFullDateFormat
public static DateTimeFormat getFullDateFormat()(Code)



getFullDateTimeFormat
public static DateTimeFormat getFullDateTimeFormat()(Code)



getFullTimeFormat
public static DateTimeFormat getFullTimeFormat()(Code)



getLongDateFormat
public static DateTimeFormat getLongDateFormat()(Code)



getLongDateTimeFormat
public static DateTimeFormat getLongDateTimeFormat()(Code)



getLongTimeFormat
public static DateTimeFormat getLongTimeFormat()(Code)



getMediumDateFormat
public static DateTimeFormat getMediumDateFormat()(Code)



getMediumDateTimeFormat
public static DateTimeFormat getMediumDateTimeFormat()(Code)



getMediumTimeFormat
public static DateTimeFormat getMediumTimeFormat()(Code)



getPattern
public String getPattern()(Code)



getShortDateFormat
public static DateTimeFormat getShortDateFormat()(Code)



getShortDateTimeFormat
public static DateTimeFormat getShortDateTimeFormat()(Code)



getShortTimeFormat
public static DateTimeFormat getShortTimeFormat()(Code)



parse
public Date parse(String text)(Code)
Parses text to produce a Date value. An IllegalArgumentException is thrown if either the text is empty or if the parse does not consume all characters of the text.
Parameters:
  text - the string being parsed a parsed date/time value
throws:
  IllegalArgumentException - if the entire text could not be convertedinto a number



parse
public int parse(String text, int start, Date date)(Code)
This method parses the input string, fill its value into a Date .
Parameters:
  text - the string that need to be parsed
Parameters:
  start - the character position in "text" where parsing should start
Parameters:
  date - the date object that will hold parsed value 0 if parsing failed, otherwise the number of characters advanced



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.