Guest User

Untitled

a guest
Apr 25th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. Person person = allPeople.get(id);
  2.  
  3. // принимаем строчку Wed Dec 09 00:00:00 MSK 1998 и переводим в oldDateFormat:
  4. String string = allPeople.get(id).getBirthDay().toString();
  5. SimpleDateFormat oldDateFormat = new SimpleDateFormat("E MM hh:mm:ss z yyyy", Locale.ENGLISH);
  6. SimpleDateFormat newDateFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH);
  7.  
  8. // date "забирает" на себя отформатированную ранее строку:
  9. Date date = oldDateFormat.parse(string);
  10. // и пробуем привести под более читабельный формат dd-MM-yyyy:
  11. String result = newDateFormat.format(date);
  12. Date date2 = newDateFormat.parse(result);
Add Comment
Please, Sign In to add comment