net.rim.device.api.io.http
Class HttpDateParser

java.lang.Object
  extended by net.rim.device.api.io.http.HttpDateParser

public final class HttpDateParser
extends Object

A little utility class designed to parse dates in one of the three formats supported by HTTP 1.1. The formats are:

Note that the first format is preferred, and in fact HTTP 1.1 clients and servers MUST only generate dates in that format. However, for backwards compatibility, they MUST accept all three formats.

Sample code
 // Assuming getHeaderField() of HttpConnection interface is implemented.
 String value = getHeaderField( HttpProtocolConstants.HEADER_DATE ); 
 if (value != null) 
 {
     long parsed = HttpDateParser.parse( value );
 }
 

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0

Method Summary
Category: Signed static long parse(String date)
          Parses a date string and returns the number of milliseconds since January 1, 1970, 00:00:00 GMT.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Method Detail

parse

public static long parse(String date)
Parses a date string and returns the number of milliseconds since January 1, 1970, 00:00:00 GMT. The date is assumed to be of the format: When parsing a date string using the abbreviated year pattern ("YY") it must interpret the abbreviated year relative to some century. It does this using the algorithm described in http://tools.ietf.org/id/draft-ietf-httpstate-cookie-09.txt, section 5.5.1:
   3.  If the year-value is greater than 68 and less than 100, increment
       the year-value by 1900.
   4.  If the year-value is greater than or equal to 0 and less than 69,
       increment the year-value by 2000.
 

Parameters:
date - The string to parse.
Returns:
The number of milliseconds.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 4.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal