Android - get the date from sending SMS in milliseconds

Is it possible to convert the date value of the Sms table, for example. 1293457709636 (miliseconds) to a meaningful time value.

+3
source share
2 answers

simply

long ms = 1293457709636; // or whatever you have read from sms
Date dateFromSms = new Date(ms);
+5
source

You can convert the Sms table date to a Date time value like this.

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS");
Calendar calendar = Calendar.getInstance();
long now = 1293457709636L;
calendar.setTimeInMillis(now);
Log.i("time", "time"+formatter.format(calendar.getTime()));
+4
source

Source: https://habr.com/ru/post/1782299/


All Articles