Date dt = new Date();
Calendar cl = new GregorianCalendar();
cl.setTime(dt);
cl.add(Calendar.DATE, -1);
Date dt2 = new Date();
dt2.setTime(cl.getTime().getTime());
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yy");
String result = formatter.format(dt2);
System.out.println(result);
Calendar cl = new GregorianCalendar();
cl.setTime(dt);
cl.add(Calendar.DATE, -1);
Date dt2 = new Date();
dt2.setTime(cl.getTime().getTime());
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yy");
String result = formatter.format(dt2);
System.out.println(result);
Demikian contoh program Simple Date Format dengan tambahan Calendar dan Date pada JAVA, semoga bermanfaat.
GBU.
Related Posts
0 comments:
Posting Komentar