Class DateParser


  • public class DateParser
    extends java.lang.Object
    **** [1] W3C license (jigsaw license) *****

    Jigsaw Copying Conditions

    W3C IPR SOFTWARE NOTICE

    Copyright © 1995-1998 World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/

    This W3C work (including software, documents, or other related items) is being provided by the copyright holders under the following license. By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions:

    Permission to use, copy, and modify this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the software and documentation or portions thereof, including modifications, that you make:

    1. The full text of this NOTICE in a location viewable to users of the redistributed or derivative work. 2. Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, a short notice of the following form (hypertext is preferred, text is permitted) should be used within the body of any redistributed or derivative code: "Copyright © World Wide Web Consortium, (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/" 3. Notice of any changes or modifications to the W3C files, including the date changes were made. (We recommend you provide URIs to the location from which the code is derived).

    In addition, creators of derivitive works must include the full text of this NOTICE in a location viewable to users of the derivitive work.

    THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.

    COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.

    The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the software without specific, written prior permission. Title to copyright in this software and any associated documentation will at all times remain with copyright holders.

    ____________________________________

    This formulation of W3C's notice and license became active on August 14 1998. See the older formulation for the policy prior to this date. Please see our Copyright FAQ for common questions about using materials from our site, including specific terms and conditions for packages like libwww, Amaya, and Jigsaw. Other questions about this notice can be directed to site-policy@w3.org .

    webmaster (last updated 14-Aug-1998) **** end W3C license (jigsaw license) *****

    • Constructor Summary

      Constructors 
      Constructor Description
      DateParser()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private boolean checkValueAndNext​(java.util.StringTokenizer st, java.lang.String token)
      Check if the next token, if exists, has a given value and that the provided string tokenizer has more tokens after that.
      private java.util.Calendar getCalendar​(java.lang.String iso8601Date)
      Check if a given date is an iso8601 date.
      java.util.Date parse​(java.lang.String iso8601DateAsString)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DateParser

        public DateParser()
    • Method Detail

      • checkValueAndNext

        private boolean checkValueAndNext​(java.util.StringTokenizer st,
                                          java.lang.String token)
                                   throws InvalidDateException
        Check if the next token, if exists, has a given value and that the provided string tokenizer has more tokens after that. It consumes the token checked against the expected value from the string tokenizer.
        Parameters:
        st - The StringTokenizer to check.
        token - The value expected for the next token.
        Returns:
        true if the token matches the value and there are more tokens. false if there are no more tokens and we do not have a token to check.
        Throws:
        InvalidDateException - If the token does not match the value or if there are no more tokens after the token that matches the expected value.
      • getCalendar

        private java.util.Calendar getCalendar​(java.lang.String iso8601Date)
                                        throws InvalidDateException
        Check if a given date is an iso8601 date.
        Parameters:
        iso8601Date - The date to be checked.
        Returns:
        true if the date is an iso8601 date.
        Throws:
        InvalidDateException
      • parse

        public java.util.Date parse​(java.lang.String iso8601DateAsString)
                             throws InvalidDateException
        Parameters:
        iso8601DateAsString - The date parameter as a String.
        Returns:
        The corresponding Date object representing the result of parsing the date parameter.
        Throws:
        InvalidDateException - In case of an invalid date.