Here you can find the source of StringToDateFormat(String str, String format)
Parameter | Description |
---|---|
str | yyyy-mm-dd |
Parameter | Description |
---|---|
ParseException | an exception |
public static Date StringToDateFormat(String str, String format) throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**// ww w. ja v a 2 s . c o m * * @param str yyyy-mm-dd * @return date * @throws ParseException */ public static Date StringToDateFormat(String str, String format) throws ParseException { Date dt = new Date(); if (str != null && !str.equals("")) { SimpleDateFormat transFormat = new SimpleDateFormat(format); dt = transFormat.parse(str); } return dt; } }