Here you can find the source of convertToDate(String str, String format)
Parameter | Description |
---|---|
str | a parameter |
format | a parameter |
Parameter | Description |
---|---|
ParseException | an exception |
public static Date convertToDate(String str, String format) throws ParseException
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static Date convertToDate(String str) throws ParseException { return convertToDate(str, DEFAULT_FORMAT); }// w w w . j a v a2s.c o m public static Date convertToDate(String str, String format) throws ParseException { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format); return simpleDateFormat.parse(str); } }