Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. private String getMonth(String date) throws ParseException {
  2. Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH).parse(date);
  3. Calendar cal = Calendar.getInstance();
  4. cal.setTime(d);
  5. String monthName = new SimpleDateFormat("MMM").format(cal.getTime());
  6. return monthName;
  7. }
  8. private String getDate(String date) throws ParseException{
  9. Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH).parse(date);
  10. Calendar cal = Calendar.getInstance();
  11. cal.setTime(d);
  12. String dateName = new SimpleDateFormat("dd").format(cal.getTime());
  13. return dateName;
  14. }
  15. private String getYear(String date) throws ParseException{
  16. Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH).parse(date);
  17. Calendar cal = Calendar.getInstance();
  18. cal.setTime(d);
  19. String yearName = new SimpleDateFormat("yyyy").format(cal.getTime());
  20. return yearName;
  21. }
  22.  
  23. private String getTime(String date) throws ParseException{
  24. Date d = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH).parse(date);
  25. Calendar cal = Calendar.getInstance();
  26. cal.setTime(d);
  27. String timeName = new SimpleDateFormat("hh:mm a").format(cal.getTime());
  28. return timeName;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement