androd System.currentTimeMillis函数记录

Java UTC时间戳:

System.currentTimeMillis返回的是:UTC 1970-01-01 00:00:00 到现在的毫秒数。

这个函数已经将Locale Time转换为UTC 时间了。


实验如下: 这个函数返回值为61000毫秒!


public static long currentTimeSecsUTC() {


        long utcs = 0;


        String date1 = "1970-01-01 08:01:01";


        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


        try {
            Date date = sdf.parse(date1);
            Calendar cal = Calendar.getInstance();
            cal.setTime(date);
            utcs = cal.getTimeInMillis();
            System.out.println("utcs = " + utcs);
        } catch (ParseException e) {
            e.printStackTrace();
        }


        return utcs;


    }


你可能感兴趣的:(Java,Android)