Here you can find the source of parseGeneralizedTimeAsDate(String generalizedTime)
Parameter | Description |
---|---|
generalizedTime | the string representation of the date/time in the format YYYYMMDDHHMMSS. |
Parameter | Description |
---|---|
ParseException | Whenever a parse exception occurs. |
public static Date parseGeneralizedTimeAsDate(String generalizedTime) throws ParseException
//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; } }