// Create a calendar instance with system current time. Calendar calendar = Calendar.getInstance();
// Formating the time . SimpleDateFormat dateFormat = new SimpleDateFormat("H:mm:ss:SSS"); System.out.println("Current Time(H:mm:ss:SSS) :"+ dateFormat.format(calendar.getTime()));
// Another Format dateFormat = new SimpleDateFormat("yyyyMMdd"); System.out.println("Current Time(yyyyMMdd):"+ dateFormat.format(calendar.getTime()));
// Custom Formating. int currentHour = calendar.get(Calendar.HOUR); int currentMinute = calendar.get(Calendar.MINUTE); int currentSeconds = calendar.get(Calendar.SECOND);