Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class TimeTool {
public Date stringToDate(String dateString){
Date date = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
try {
date = sdf.parse(dateString);
} catch(ParseException e) {
}
return date;
}
public String dateToString(Date date){
SimpleDateFormat ft = new SimpleDateFormat ("yyyy/MM/dd HH:mm:ss");
String dateString = ft.format(date);
return dateString;
}
public String getCurrentTimeString(){
SimpleDateFormat ft = new SimpleDateFormat ("yyyy/MM/dd HH:mm:ss");
String dateString = ft.format(new Date());
return dateString;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.