Best way to retrieve sqlite date

1

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

    
asked by anonymous 20.12.2014 / 00:46

1 answer

1

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

And to improve the process, I find it easier to save the date in the database in milliseconds, so to convert to Date is just to do:

new Date(long)

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