Calendar time = Calendar.getInstance(); int hour = time.get(Calendar.HOUR_OF_DAY); int minute = time.get(Calendar.MINUTE); int year = time.get(Calendar.YEAR); int day = time.get(Calendar.DAY_OF_MONTH); int month = time.get(Calendar.MONTH) +1; String t =""+ year +"-"+ month +"-"+ day +"-"+ hour +":"+ minute;