Here you can find the source of parse(String date)
Parameter | Description |
---|---|
date | String to be parsed |
Parameter | Description |
---|---|
ParseException | inherited from SimpleDateFormat.parse(String) |
public static Date parse(String date) throws ParseException
//package com.java2s; /*//from www.j a va2 s .co m Copyright 2012 Juan Mart?n Runge jmrunge@gmail.com http://www.zirsi.com.ar This file is part of ZirUtils. ZirUtils is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ZirUtils 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 General Public License for more details. You should have received a copy of the GNU General Public License along with ZirUtils. If not, see <http://www.gnu.org/licenses/>. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** * Method for parsing a String into a date with default format (dd/MM/yyyy) * * @param date String to be parsed * @return resultant Date Object * @throws ParseException inherited from SimpleDateFormat.parse(String) * @see java.text.SimpleDateFormat */ public static Date parse(String date) throws ParseException { return parse(date, null); } /** * Method for parsing a String into a Date with specified format * * @param date String to be parsed * @param format the format * @return resultant Date Object * @throws ParseException inherited from SimpleDateFormat.parse(String) * @see java.text.SimpleDateFormat */ public static Date parse(String date, String format) throws ParseException { if (date == null) return null; if (format == null) format = "dd/MM/yyyy"; SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.parse(date); } }