Java Parse Date parseDateFromDefault(String dateString)

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

Description

Parse a string in standard input format, in the default time zone, into a Date.

License

Apache License

Parameter

Parameter Description
dateString The input string

Exception

Parameter Description
ParseException if the date is not in the proper format.

Return

The Date.

Declaration

public static Date parseDateFromDefault(String dateString)
        throws ParseException 

Method Source Code

//package com.java2s;
/**********************************************************************************
 * $URL$/*from   ww  w  .j ava2 s .  com*/
 * $Id$
 ***********************************************************************************
 *
 * Copyright (c) 2012, 2013 Etudes, Inc.
 * 
 * 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.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class Main {
    /**
     * Parse a string in standard input format, in the default time zone, into a Date.
     * 
     * @param dateString
     *        The input string
     * @return The Date.
     * @throws ParseException
     *         if the date is not in the proper format.
     */
    public static Date parseDateFromDefault(String dateString)
            throws ParseException {
        if ((dateString == null) || (dateString.trim().length() == 0))
            return null;
        DateFormat format = DateFormat.getDateTimeInstance(
                DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault());
        format.setTimeZone(TimeZone.getDefault());
        Date rv = format.parse(dateString);
        return rv;
    }
}

Related

  1. parseDateForFilter(String date)
  2. parseDateFormat(String s, String pattern, TimeZone tz)
  3. parseDateFrom(String dateStr)
  4. parseDateFromDateStr(String date)
  5. parseDateFromDateTimeStr(String date)
  6. parseDateFromHeader(String datestr)
  7. parseDateFromString(String valor, String formatoFecha)
  8. parseDateHeader(String header)
  9. parseDateHeader(String value)