日期时间

当前年月日

long time = System.currentTimeMillis();
Date date = new Date(time);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.format(date);

DateUtils.getCurrentTime("yyyy-MM-dd HH:mm:ss")

/**
 * 据指定格式获当前时
 *
 * @param format
 * @return String
 */
public static String getCurrentTime(String format) {
    SimpleDateFormat sdf = DateFormatUtils.getFormat(format);
    Date date = new Date();
    return sdf.format(date);
}

猜你喜欢

转载自blog.csdn.net/zsp_android_com/article/details/80713635