import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateAndString {
public String dateToString(Date date){
String datetime = null;
SimpleDateFormat timeFormat = null;
timeFormat = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
datetime = timeFormat.format(date);
return datetime;
}
public Date stringToDate(String time){
Date date = null;
SimpleDateFormat timeFormat = null;
timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
date = timeFormat.parse(time);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
}