Here you can find the source of parseDateFromDefault(String dateString)
Parameter | Description |
---|---|
dateString | The input string |
Parameter | Description |
---|---|
ParseException | if the date is not in the proper format. |
public static Date parseDateFromDefault(String dateString) throws ParseException
//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; } }