Here you can find the source of convertStringToDate(String aMask, String strDate)
Parameter | Description |
---|---|
aMask | the date pattern the string is in |
strDate | a string representation of a date |
Parameter | Description |
---|---|
ParseException | an exception |
public static final Date convertStringToDate(String aMask, String strDate)
//package com.java2s; //License from project: LGPL import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*from w ww. ja v a 2 s.c o m*/ * This method generates a string representation of a date/time in the format you specify on input * @param aMask * the date pattern the string is in * @param strDate * a string representation of a date * @return a converted Date object * @see java.text.SimpleDateFormat * @throws ParseException */ public static final Date convertStringToDate(String aMask, String strDate) { SimpleDateFormat df = null; Date date = null; df = new SimpleDateFormat(aMask); try { date = df.parse(strDate); } catch (ParseException pe) { throw new IllegalArgumentException(pe.getMessage() + " " + pe.getErrorOffset()); } return (date); } }