Java Parse Date Pattern YYYY parseGeneralizedTimeAsDate(String generalizedTime)

Here you can find the source of parseGeneralizedTimeAsDate(String generalizedTime)

Description

Parses a generalized time as a date ignoring hour minute seconds.

License

Open Source License

Parameter

Parameter Description
generalizedTime the string representation of the date/time in the format YYYYMMDDHHMMSS.

Exception

Parameter Description
ParseException Whenever a parse exception occurs.

Return

the parsed date or null.

Declaration

public static Date parseGeneralizedTimeAsDate(String generalizedTime) throws ParseException 

Method Source Code


//package com.java2s;
/*//  w w w . j a  v  a  2  s.c  o m
 * Copyright (c) 2005-2016 Vincent Vandenschrick. All rights reserved.
 *
 *  This file is part of the Jspresso framework.
 *
 *  Jspresso is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Jspresso is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Jspresso.  If not, see <http://www.gnu.org/licenses/>.
 */

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

public class Main {
    /**
     * Parses a generalized time as a date ignoring hour minute seconds.
     *
     * @param generalizedTime
     *          the string representation of the date/time in the format
     *          YYYYMMDDHHMMSS.
     * @return the parsed date or null.
     * @throws ParseException
     *           Whenever a parse exception occurs.
     */
    public static Date parseGeneralizedTimeAsDate(String generalizedTime) throws ParseException {
        if (generalizedTime != null) {
            return new SimpleDateFormat("yyyyMMdd").parse(generalizedTime.substring(0, 8));
        }
        return null;
    }
}

Related

  1. parseExpireField(String timestring)
  2. parseFormattedTime(String formattedTime)
  3. parseFTPDate(String dateStr)
  4. parseFullDate(String paramName, String dateStr)
  5. parseFullTime(String str)
  6. parseHeaderDate(String headerValue)
  7. parseHHMMSS(long time)
  8. parseInsituFileNameDateFormat(String timeString)
  9. parseLastModifDate(final File file)