Question Detail

I want to add Current dateTime in my database Table while running SQLite Query to Save Data in Table.

How do I display the current date and time in an Android application?


Thread Reply

Hemant Sharma

- 11 months ago

You need to pass todayDay() in your SQL Query where you want current DateTime

String todayDay() {
    Calendar calendar = Calendar.getInstance();
    Date today = calendar.getTime();
    calendar.add(Calendar.DAY_OF_YEAR, 1);
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh-mm-ss");;
    return dateFormat.format(today);
}