开发者

Android - get date time from SMS timestamp in miliseconds

开发者 https://www.devze.com 2023-02-01 02:48 出处:网络
is it possible to convert Sms table date valuee.g. 1293457709636 (miliseconds) to meaningful Date t开发者_运维百科ime value.just do

is it possible to convert Sms table date value e.g. 1293457709636 (miliseconds) to meaningful Date t开发者_运维百科ime value.


just do

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


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()));
0

精彩评论

暂无评论...
验证码 换一张
取 消