类 DateUtils

java.lang.Object
cn.zhxu.toys.util.DateUtils

public class DateUtils extends Object
日期工具类
从以下版本开始:
0.3.3
作者:
Troy.Zhou
  • 字段详细资料

  • 构造器详细资料

    • DateUtils

      public DateUtils()
  • 方法详细资料

    • format

      public static String format(Date date, String pattern)
      格式化日期
    • parse

      public static Date parse(String date, String pattern)
      解析日期
    • formatYear

      public static String formatYear(Date date)
      按 yyyy 格式化日期
    • parseYear

      public static Date parseYear(String date)
      按 yyyy 解析日期
    • formatMonth

      public static String formatMonth(Date date)
      按 yyyy-MM 格式化日期
    • parseMonth

      public static Date parseMonth(String date)
      按 yyyy-MM 解析日期
    • formatDate

      public static String formatDate(Date date)
      按 yyyy-MM-dd 格式化日期
    • parseDate

      public static Date parseDate(String date)
      按 yyyy-MM-dd 解析日期
    • formatDateTime

      public static String formatDateTime(Date date)
      按 yyyy-MM-dd HH:mm 格式化日期
    • parseDateTime

      public static Date parseDateTime(String date)
      按 yyyy-MM-dd HH:mm 解析日期
    • formatMills

      public static String formatMills(Date date)
      按 yyyyMMddHHmmssSSS 格式化日期
    • parseMills

      public static Date parseMills(String date)
      按 yyyyMMddHHmmssSSS 解析日期
    • dateCeil

      public static Date dateCeil(Date date)
      日期向上取整(下一天刚开始)
    • dateFloor

      public static Date dateFloor(Date date)
      日期向下取整(当天刚开始)
    • dateAdd

      public static Date dateAdd(Date date, int years, int months, int days)
      日期增加
      参数:
      date - 被增加日期
      years - 增加的年数
      months - 增加的月数
      days - 增加的天数
      返回:
    • addYears

      public static Date addYears(Date date, int years)
      years 年以后
    • addMonths

      public static Date addMonths(Date date, int months)
      months 月以后
    • addDays

      public static Date addDays(Date date, int days)
      days 天以后
    • nextDay

      public static Date nextDay(Date date)
      下一天
    • prevDay

      public static Date prevDay(Date date)
      前一天
    • timeAdd

      public static Date timeAdd(Date date, int hours, int minutes, int seconds, int millis)
      日期增加
      参数:
      date - 被增加日期
      hours - 添加的小时数
      minutes - 添加的分钟数
      seconds - 添加的秒数
      millis - 添加的毫秒数
      返回:
      Date
    • addHours

      public static Date addHours(Date date, int hours)
      hours 小时以后
    • addMinutes

      public static Date addMinutes(Date date, int minutes)
      minutes 分钟以后
    • addSeconds

      public static Date addSeconds(Date date, int seconds)
      seconds 秒以后
    • daysOfMonth

      public static int daysOfMonth(String month)
      获取某月的天数
      参数:
      month - 月份(yyyy-MM)
      返回:
      天数
    • daysOfMonth

      public static int daysOfMonth(Date month)
      获取某月的天数
      参数:
      month - 月份
      返回:
      天数
    • daysOfYear

      public static int daysOfYear(String year)
      获取某年的天数
      参数:
      year - 年(yyyy)
      返回:
      天数
    • daysOfYear

      public static int daysOfYear(Date year)
      获取某年的天数
      参数:
      year - 年
      返回:
      天数
    • todayBeginning

      public static Date todayBeginning()
      获取今天刚开始的时刻
      返回:
    • isMonthBeginning

      public static boolean isMonthBeginning(Date date)
      是否是月初
    • isMonthEnding

      public static boolean isMonthEnding(Date date)
      是否是月底
    • isYearBeginning

      public static boolean isYearBeginning(Date date)
      是否是年初
    • isYearEnding

      public static boolean isYearEnding(Date date)
      是否是年底
    • min

      public static Date min(Date... dates)
      最小日期
    • max

      public static Date max(Date... dates)
      最大日期
    • yearOf

      public static int yearOf(Date date)
      获取当时的年数
    • monthOf

      public static int monthOf(Date date)
      获取当时的月份
      返回:
      月份, 从0(一月)开始
      另请参阅:
    • dayOfYear

      public static int dayOfYear(Date date)
      当天在当年中所处的天数
      返回:
      天数, 从1开始
    • dayOfMonth

      public static int dayOfMonth(Date date)
      当天在当月中所处的天数
      返回:
      天数, 从1开始
    • dayOfWeek

      public static int dayOfWeek(Date date)
      获取星期
      返回:
      星期, 从0(星期日)开始
      另请参阅:
    • weekOfYear

      public static int weekOfYear(Date date)
      获取一年中的周数
      返回:
      周数
    • weekOfMonth

      public static int weekOfMonth(Date date)
      获取某一月中的周数
      返回:
      周数