类 DateUtils

java.lang.Object
com.cdkjframework.util.date.DateUtils

@Component public class DateUtils extends Object
  • 字段详细资料

  • 构造器详细资料

    • DateUtils

      public DateUtils()
  • 方法详细资料

    • parse

      public static Date parse(String dateString)
      字符串转化成日期
      参数:
      dateString - 字符串
      返回:
      日期
    • parse

      public static Date parse(String str, String pattern)
    • parse

      public static Date parse(String str, String pattern, Locale locale)
    • parseExp

      public static Date parseExp(String str, String pattern) throws Exception
      抛出:
      Exception
    • format

      public static String format(Date date)
      日期类型转字符串
      参数:
      date - 日期
      返回:
      字符串(格式为:yyyy-MM-dd)
    • format

      public static String format(Date date, String pattern)
      日期类型转字符串
      参数:
      date - 日期
      pattern - 格式
      返回:
      字符串
    • splitByDay

      public static List<Date> splitByDay(Date startDate, Date endDate)
      将某个时间范围按天进行切分,未满一天的按一天算
      参数:
      startDate - 开始时间
      endDate - 结束时间
      返回:
      日期集合
    • isSameDay

      public static boolean isSameDay(Date date1, Date date2)
      判断两个时间是否在同一天内
      参数:
      date1 - 时间
      date2 - 时间
      返回:
      true=同一天;false=非同一天;
    • isSameMonth

      public static boolean isSameMonth(Date date1, Date date2)
      判断两个时间是否在同一个月内
      参数:
      date1 - 时间
      date2 - 时间
      返回:
      true=在同一个月内;false=不在同一个月内;
    • isSameQuarter

      public static boolean isSameQuarter(Date date1, Date date2)
      判断两个时间是否在同一季度里
      参数:
      date1 - 时间
      date2 - 时间
      返回:
      true=在同一个季度内;false=不在同一个季度内;
    • betDate

      public static long betDate(Date date, Date otherDate)
      得到两个时间的差额
      参数:
      date - 时间
      otherDate - 时间
      返回:
      时间差额
    • getCurrentTime

      public static long getCurrentTime()
      获取当前日期
      返回:
      long(毫秒)
    • getCurrentDate

      public static Date getCurrentDate()
      获取当前日期
      返回:
      Date
    • getCurrentCalendar

      public static Calendar getCurrentCalendar()
      获取当前日期
      返回:
      Calendar
    • calendarToString

      public static String calendarToString(Calendar calendar, String template)
    • timeCompare

      public static String timeCompare(Date nowArg, Date dateArg)
      比较时间差 1小时内的显示:** 分钟前,例如:25 分钟前 1小时前(1天内的):今天 **时:**分,例如: 08:17 1天前的(当前年):*月*号 **时:**分,例如:05-09 23:58 当前年之前的:年-月-日 **时:**分,例如:2009-09-26 16:33
    • getFormatTime

      public static long getFormatTime(long time)
    • getFormatTime

      public static long getFormatTime(Date date)
      获取格式化时间
      参数:
      date - 时间
      返回:
      返回时间戳
    • subtractParse

      public static String subtractParse(long deltaMillis, String format)
      参数:
      deltaMillis - 时差毫秒表示
      返回:
      Description:
      给定时间差解析成中文表示(只计算过去的某个时间和当前时间的差)

      如"2小时32分"

    • subtractParse

      public static String subtractParse(Date oldTime, String format)
      参数:
      oldTime - 过去的某个时间
      format - 格式化方式 。 如dHms表示 xx天xx小时xx分钟xx秒
      返回:
      Description:
      解析过去某个时间和当前时间的差的中文表示

      如"2小时32分"