java--utils

  • date
/**
     * 獲取當天的 0:0:0-23:59:59;
     *
     * @return
     */
public static Date[] getStartAndEndOfDay() {
        Date[] dates = new Date[2];
        Calendar today = Calendar.getInstance();
        today.set(Calendar.HOUR, 0);
        today.set(Calendar.MINUTE, 0);
        today.set(Calendar.SECOND, 0);
        today.set(Calendar.MILLISECOND, 0);
        dates[0] = today.getTime();

        today.set(Calendar.HOUR, 23);
        today.set(Calendar.MINUTE, 59);
        today.set(Calendar.SECOND, 59);
        today.set(Calendar.MILLISECOND, 999);
        dates[1] = today.getTime();

        return dates;
    }
相關文章
相關標籤/搜索