Advertisement
rachmadi

Format date

Jan 19th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. public String formatDate(String datetime){
  2.         Locale id = new Locale("in", "ID");
  3.         String pattern = "yyyy-MM-dd hh:mm:ss";
  4.         SimpleDateFormat sdf = new SimpleDateFormat(
  5.                 pattern, id);
  6.         Date myDate = null;
  7.         try {
  8.             myDate = sdf.parse(datetime);
  9.  
  10.         } catch (ParseException e) {
  11.             e.printStackTrace();
  12.         }
  13.  
  14.         SimpleDateFormat tanggaldf = new SimpleDateFormat("EEEE, dd MMM yyyy, hh:mm", id);
  15.         String finalDate = tanggaldf.format(myDate);
  16.  
  17.         System.out.println(finalDate);
  18.         return finalDate;
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement