Android - get date time from SMS timestamp in miliseconds

别来无恙 提交于 2019-11-28 09:11:45

问题


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


回答1:


just do

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



回答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()));


来源:https://stackoverflow.com/questions/4539490/android-get-date-time-from-sms-timestamp-in-miliseconds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!