Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // String to Date
- String dtStart = "2010-10-15 09:27:37";
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- Date date = format.parse(dtStart);
- System.out.println(date);
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- // Date to String
- SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- Date date = new Date();
- String datetime = dateFormat.format(date);
- System.out.println("Current Date Time : " + datetime);
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement