System.currentTimeMillis() & UNIX_TIMESTAMP()*1000

import java.text.SimpleDateFormat;
import java.util.Date;

public class test {
    public static void main(String agrs[]){
        long time = System.currentTimeMillis(); //当前时间,以秒为单位
        long totalSeconds = time / 1000;
        //求出现在的秒
        long currentSecond = totalSeconds % 60;

        //求出现在的分
        long totalMinutes = totalSeconds / 60;
        long currentMinute = totalMinutes % 60;

        //求出现在的小时
        long totalHour = totalMinutes / 60;
        long currentHour = totalHour % 24;

        //显示时间
        System.out.print("总毫秒为: " + time);
        System.out.println(currentHour + ":" + currentMinute + ":" + currentSecond + " GMT");



        //显示时间
        Date nowTime = new Date(System.currentTimeMillis());
        System.out.println(System.currentTimeMillis());
        SimpleDateFormat sdFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:dd");
        String retStrFormatNowDate = sdFormatter.format(nowTime);
        System.out.println(retStrFormatNowDate);


    }
}

System.currentTimeMillis() & UNIX_TIMESTAMP()*1000_第1张图片

你可能感兴趣的:(System.currentTimeMillis() & UNIX_TIMESTAMP()*1000)