Android - get date time from SMS timestamp in miliseconds

11,364

Solution 1

just do

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

Solution 2

You can convert Sms table date in to meaningful Date time 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()));
Share:
11,364
Admin
Author by

Admin

Updated on June 05, 2022

Comments

  • Admin
    Admin almost 2 years

    is it possible to convert Sms table date value e.g. 1293457709636 (miliseconds) to meaningful Date time value.