Guest User

Untitled

a guest
Jan 20th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. String ts = "120918 10:35:45";
  2. SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd hh:mm:ss");
  3. java.util.Date parsedDate = dateFormat.parse(ts);
  4. //parsing timestamp
  5. Timestamp timestamp = new java.sql.Timestamp(parsedDate.getTime());
  6. System.out.println("timestamp after parsing :: "+timestamp);
  7.  
  8. SimpleDateFormat noMilliSecondsFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  9. System.out.println(noMilliSecondsFormatter.format(timestamp));
Add Comment
Please, Sign In to add comment