Best way to recover the sqlite date

Asked

Viewed 661 times

1

In sql that runs at the time of inserting a new record the field data_cad is current_datetime. What is the best way to show in Activity the date in the dd/MM/yyyy hh:mm:ss format? Thanks in advance.

1 answer

1


You can capture the date in a Date and then with Formatstring convert it to String and display in a Textview.

And to improve the process, I find it easier to save the date in the bank in mileseconds, so to convert in Date just do:

new Date(long)

Date data = (data do sql)
SimpleDateFormat dt1 = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
String dataFormatada = dt1.format(date));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.