Class DateUtils

java.lang.Object
org.nutz.lang.Times
club.zhcs.lina.utils.DateUtils

public class DateUtils extends org.nutz.lang.Times
Author:
Kerbores(kerbores@riemann.tech)
  • Field Details

  • Constructor Details

    • DateUtils

      public DateUtils()
  • Method Details

    • addDays

      public static Date addDays(Date base, int days)
      日期加减
      Parameters:
      base - 开始日期
      days - 增加天数 正数为之后日期负数为之前日期
      Returns:
      目标日期
    • addDays

      public static Date addDays(int days)
      从今日开始的日期加减
      Parameters:
      days - 增加天数 正数为之后日期负数为之前日期
      Returns:
      目标日期
    • daysBetween

      public static double daysBetween(Date start, Date end)
      两个日期之间的天数差
      Parameters:
      start - 开始日期
      end - 结束日期
      Returns:
      天数
    • getDayStart

      public static Date getDayStart(Date d)
      获取当日凌晨
      Parameters:
      d - 日期
      Returns:
      当日凌晨 date 对象
    • getDayEnd

      public static Date getDayEnd(Date d)
    • getDayStart

      public static Date getDayStart()
      获取今日凌晨
      Returns:
      今日凌晨0:0:0的时间实例
    • getDayEnd

      public static Date getDayEnd()
    • getWeekEnd

      public static Date getWeekEnd(boolean startFromSunday)
      获取当前日期的周结束(周日或者周六)
      Parameters:
      startFromSunday - 从周日开始计算周 标识
      Returns:
      startFromSunday 为true 则返回下一个周六 为false则返回下一个周日
    • getWeekEnd

      public static Date getWeekEnd(boolean startFromSunday, Date date)
    • getWeekStart

      public static Date getWeekStart(boolean startFromSunday)
      获取当前日期的周开始(周一或者周日)
      Parameters:
      startFromSunday - 从周日开始计算周 标识
      Returns:
      startFromSunday 为true 则返回上一个周日 为false则返回上一个周一
    • getWeekStart

      public static Date getWeekStart(boolean startFromSunday, Date date)
    • addSeconds

      public static Date addSeconds(Date base, long seconds)
      增加秒
      Parameters:
      base - 基础时间
      seconds - 秒数
      Returns:
      日期对象
    • addSeconds

      public static Date addSeconds(long seconds)
      增加秒
      Parameters:
      seconds - 秒数
      Returns:
      日期对象
    • getYearStart

      public static Date getYearStart(Date d)
      获取元旦日期
      Parameters:
      d - 日期
      Returns:
      元旦日期
    • getYearStart

      public static Date getYearStart()
      获取元旦日期
      Returns:
      元旦日期
    • getYearEnd

      public static Date getYearEnd(Date d)
      获取年末日期
      Parameters:
      d - 日期
      Returns:
      年末日期
    • getYearEnd

      public static Date getYearEnd()
      获取年末日期
      Returns:
      年末日期
    • getMonthStart

      public static Date getMonthStart(Date d)
      获取月初日期
      Parameters:
      d - 日期
      Returns:
      月初日期
    • getMonthStart

      public static Date getMonthStart()
      获取月初日期
      Returns:
      月初日期
    • getMonthEnd

      public static Date getMonthEnd(Date d)
      获取月末日期
      Parameters:
      d - 日期
      Returns:
      月末日期
    • getMonthEnd

      public static Date getMonthEnd()
      获取月末日期
      Returns:
      月末日期
    • getSequence

      public static String getSequence()
    • getYearStartMonth

      public static String getYearStartMonth()
    • getYearStartMonth

      public static String getYearStartMonth(Date date)
    • getYearEndMonth

      public static String getYearEndMonth()
    • getYearEndMonth

      public static String getYearEndMonth(Date date)
    • getMonthStartDate

      public static String getMonthStartDate()
    • getMonthStartDate

      public static String getMonthStartDate(Date date)
    • getMonthEndDate

      public static String getMonthEndDate()
    • getMonthEndDate

      public static String getMonthEndDate(Date date)
    • getDayOfMonth

      public static int getDayOfMonth()