获取当前时间

    xiaoxiao2021-03-25  151

    /** * 获取当前时间 * * @return 毫秒值 */ public static long GetCurrentTime() { Time time = new Time(); time.setToNow(); // toMillis(false)与toMillis(true)的区别:其区别在于是否支持夏令时。 return time.toMillis(false); }

    -

    -

    -

    /** * 获取当前时间 * * @return %y%m%d%H%M%S (例如: 161202170521) */ public static String GetCurrentFormatTime() { Time time = new Time(); time.setToNow(); return time.format("%y%m%d%H%M%S"); }-

    -

    -

    /** * 获取当前时间 自定义格式时例:2012/07/07 12:12:01 * 如果要2012/07/07 12:12格式的, 就 .substring(0, 14) * * @return */ public static String GetCurrentFormatTime1() { Time time = new Time(); time.setToNow(); return time.format("%y/%m/%d %H:%M:%S"); // return time.format("%y/%m/%d_%H:%M"); }

    转载请注明原文地址: https://ju.6miu.com/read-12031.html

    最新回复(0)