Skip to content

Instantly share code, notes, and snippets.

@fbukevin
Created December 28, 2016 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbukevin/b4b68fc8ddf49fc0af48170659bb609b to your computer and use it in GitHub Desktop.
Save fbukevin/b4b68fc8ddf49fc0af48170659bb609b to your computer and use it in GitHub Desktop.
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