You can use the following method to get the current time.
/************************************************************** * getCurrentTime() it will return system time * * @return ****************************************************************/ public static String getCurrentTime() { DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd HHmmss"); Calendar cal = Calendar.getInstance(); return dateFormat.format(cal.getTime()); }// end of getCurrentTime()
source share