Java Parse Date Pattern YYYY parseXEP0082Date(String dateString)

Here you can find the source of parseXEP0082Date(String dateString)

Description

Parses the given date string in the XEP-0082 - XMPP Date and Time Profiles format.

License

Open Source License

Parameter

Parameter Description
dateString the date string to parse

Exception

Parameter Description
ParseException if the specified string cannot be parsed

Return

the parsed Date

Declaration

public static Date parseXEP0082Date(String dateString) throws ParseException 

Method Source Code

//package com.java2s;
/**/*from   w w  w.j av a  2  s  .co  m*/
 * $RCSfile$
 * $Revision: 11823 $
 * $Date: 2010-08-15 08:20:48 -0500 (Sun, 15 Aug 2010) $
 *
 * Copyright 2003-2007 Jive Software.
 *
 * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    /**
     * Date format as defined in XEP-0082 - XMPP Date and Time Profiles. The time zone is set to
     * UTC.
     * <p>
     * Date formats are not synchronized. Since multiple threads access the format concurrently, it
     * must be synchronized externally or you can use the convenience methods
     * {@link #parseXEP0082Date(String)} and {@link #formatXEP0082Date(Date)}.
     */
    public static final DateFormat XEP_0082_UTC_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");

    /**
     * Parses the given date string in the XEP-0082 - XMPP Date and Time Profiles format.
     * 
     * @param dateString the date string to parse
     * @return the parsed Date
     * @throws ParseException if the specified string cannot be parsed
     */
    public static Date parseXEP0082Date(String dateString) throws ParseException {
        synchronized (XEP_0082_UTC_FORMAT) {
            return XEP_0082_UTC_FORMAT.parse(dateString);
        }
    }
}

Related

  1. parseW3CDate(String dateString)
  2. parseW3CDateRobust(String dateString)
  3. parseW3CDateTime(String date)
  4. parseW3CDateTime(String sDate, Locale locale)
  5. parseWsDate(String date)
  6. parseXsdDate(final Date date)
  7. parseXsdDateTime(String date)
  8. parseYmd(String date)
  9. parseYmd(String s)