Question Detail

How do I Display the current Time and Date in an Android application ?

6 years ago Views 1412 Visit Post Reply

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

- 6 years 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);