Android获取时间方法

    xiaoxiao2021-12-02  35

    方法一:

    long nowLongTime = System.currentTimeMillis();  //获取时间的long类型。 Calendar cal = Calendar.getInstance(); int month = cal.get(Calendar.MONTH) + 1; int day = cal.get(Calendar.DAY_OF_MONTH); //本月中的第几天 int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); int second = cal.get(Calendar.SECOND);

    方法二:

    Time nowTime = new Time(); nowTime.setToNow(); int year = nowTime.year; int month = nowTime.month + 1; int day = nowTime.monthDay; int hour = nowTime.hour; int minute = nowTime.minute;   int second = nowTime.second;  
    转载请注明原文地址: https://ju.6miu.com/read-679765.html

    最新回复(0)