程序包 dev.utils.common

类 DateUtils

java.lang.Object
dev.utils.common.DateUtils

public final class DateUtils extends Object
detail: 日期工具类
作者:
Ttt
  • 方法详细资料

    • getDefaultFormat

      public static SimpleDateFormat getDefaultFormat()
      获取默认 SimpleDateFormat ( yyyy-MM-dd HH:mm:ss )
      返回:
      SimpleDateFormat
    • getSafeDateFormat

      public static SimpleDateFormat getSafeDateFormat(String pattern)
      获取对应时间格式线程安全 SimpleDateFormat
      参数:
      pattern - 时间格式
      返回:
      SimpleDateFormat
    • getCalendar

      public static Calendar getCalendar()
      获取 Calendar
      返回:
      Calendar
    • getCalendar

      public static Calendar getCalendar(long millis)
      获取 Calendar
      参数:
      millis - 时间毫秒
      返回:
      Calendar
    • getCalendar

      public static Calendar getCalendar(Date date)
      获取 Calendar
      参数:
      date - 日期
      返回:
      Calendar
    • getCalendar

      public static Calendar getCalendar(String time)
      获取 Calendar
      参数:
      time - 时间
      返回:
      Calendar
    • getCalendar

      public static Calendar getCalendar(String time, String pattern)
      获取 Calendar
      参数:
      time - 时间
      pattern - 时间格式
      返回:
      Calendar
    • getCalendar

      public static Calendar getCalendar(String time, SimpleDateFormat format)
      获取 Calendar
      参数:
      time - 时间
      format - SimpleDateFormat
      返回:
      Calendar
    • getCurrentTime

      public static Date getCurrentTime()
      获取当前时间 Date
      返回:
      当前时间 Date
    • getCurrentTimeMillis

      public static long getCurrentTimeMillis()
      获取当前时间毫秒
      返回:
      当前时间毫秒
    • getDateTime

      public static long getDateTime(Date date)
      获取 Date Time
      参数:
      date - 日期
      返回:
      Date Time
    • getDateNow

      public static String getDateNow()
      获取当前时间的字符串
      返回:
      当前时间的字符串
    • getDateNow

      public static String getDateNow(String pattern)
      获取当前时间的字符串
      参数:
      pattern - 时间格式
      返回:
      当前时间的字符串
    • getDateNow

      public static String getDateNow(SimpleDateFormat format)
      获取当前时间的字符串
      参数:
      format - SimpleDateFormat
      返回:
      当前时间的字符串
    • formatDate

      public static String formatDate(Date date)
      将 Date 转换日期字符串
      参数:
      date - 日期
      返回:
      按照指定格式的日期字符串
    • formatDate

      public static String formatDate(Date date, String pattern)
      将 Date 转换日期字符串
      参数:
      date - 日期
      pattern - 时间格式
      返回:
      按照指定格式的日期字符串
    • formatDate

      public static String formatDate(Date date, SimpleDateFormat format)
      将 Date 转换日期字符串
      参数:
      date - 日期
      format - SimpleDateFormat
      返回:
      按照指定格式的日期字符串
    • formatTime

      public static String formatTime(long millis)
      将时间毫秒转换日期字符串
      参数:
      millis - 时间毫秒
      返回:
      按照指定格式的日期字符串
    • formatTime

      public static String formatTime(long millis, String pattern)
      将时间毫秒转换日期字符串
      参数:
      millis - 时间毫秒
      pattern - 时间格式
      返回:
      按照指定格式的日期字符串
    • formatTime

      public static String formatTime(long millis, SimpleDateFormat format)
      将时间毫秒转换日期字符串
      参数:
      millis - 时间毫秒
      format - SimpleDateFormat
      返回:
      按照指定格式的日期字符串
    • parseDate

      public static Date parseDate(long millis)
      将时间毫秒转换成 Date
      参数:
      millis - 时间毫秒
      返回:
      Date
    • parseDate

      public static Date parseDate(String time)
      解析时间字符串转换为 Date
      参数:
      time - 时间
      返回:
      Date
    • parseDate

      public static Date parseDate(String time, String pattern)
      解析时间字符串转换为 Date
      参数:
      time - 时间
      pattern - 时间格式
      返回:
      Date
    • parseDate

      public static Date parseDate(String time, SimpleDateFormat format)
      解析时间字符串转换为 Date
      参数:
      time - 时间
      format - SimpleDateFormat
      返回:
      Date
    • parseLong

      public static long parseLong(String time)
      解析时间字符串转换为 long 毫秒
      参数:
      time - 时间
      返回:
      毫秒时间
    • parseLong

      public static long parseLong(String time, String pattern)
      解析时间字符串转换为 long 毫秒
      参数:
      time - 时间
      pattern - 时间格式
      返回:
      毫秒时间
    • parseLong

      public static long parseLong(String time, SimpleDateFormat format)
      解析时间字符串转换为 long 毫秒
      参数:
      time - 时间
      format - SimpleDateFormat
      返回:
      毫秒时间
    • parseStringDefault

      public static String parseStringDefault(String time, String pattern)
      解析时间字符串转换为指定格式字符串
      参数:
      time - 需要转换的时间
      pattern - 把 time 转换成需要的格式
      返回:
      转换指定格式的时间字符串
    • parseStringDefault

      public static String parseStringDefault(String time, SimpleDateFormat format)
      解析时间字符串转换为指定格式字符串
      参数:
      time - 需要转换的时间
      format - 把 time 转换成需要的格式
      返回:
      转换指定格式的时间字符串
    • parseString

      public static String parseString(String time, String timePattern, String pattern)
      解析时间字符串转换为指定格式字符串
      参数:
      time - 需要转换的时间
      timePattern - time 的时间格式
      pattern - 把 time 转换成需要的格式
      返回:
      转换指定格式的时间字符串
    • parseString

      public static String parseString(String time, SimpleDateFormat timeFormat, SimpleDateFormat format)
      解析时间字符串转换为指定格式字符串
      参数:
      time - 需要转换的时间
      timeFormat - time 的时间格式
      format - 把 time 转换成需要的格式
      返回:
      转换指定格式的时间字符串
    • getYear

      public static int getYear(Calendar calendar)
      获取年份
      参数:
      calendar - Calendar
      返回:
      年份
    • getYear

      public static int getYear()
      获取年份
      返回:
      年份
    • getYear

      public static int getYear(long millis)
      获取年份
      参数:
      millis - 时间毫秒
      返回:
      年份
    • getYear

      public static int getYear(Date date)
      获取年份
      参数:
      date - 日期
      返回:
      年份
    • getYear

      public static int getYear(String time)
      获取年份
      参数:
      time - 时间
      返回:
      年份
    • getYear

      public static int getYear(String time, String pattern)
      获取年份
      参数:
      time - 时间
      pattern - 时间格式
      返回:
      年份
    • getYear

      public static int getYear(String time, SimpleDateFormat format)
      获取年份
      参数:
      time - 时间
      format - SimpleDateFormat
      返回:
      年份
    • getMonth

      public static int getMonth(Calendar calendar)
      获取月份 ( 0 - 11 ) + 1
      参数:
      calendar - Calendar
      返回:
      月份
    • getMonth

      public static int getMonth()
      获取月份 ( 0 - 11 ) + 1
      返回:
      月份
    • getMonth

      public static int getMonth(long millis)
      获取月份 ( 0 - 11 ) + 1
      参数:
      millis - 时间毫秒
      返回:
      月份
    • getMonth

      public static int getMonth(Date date)
      获取月份 ( 0 - 11 ) + 1
      参数:
      date - 日期
      返回:
      月份
    • getMonth

      public static int getMonth(String time)
      获取月份 ( 0 - 11 ) + 1
      参数:
      time - 时间
      返回:
      月份
    • getMonth

      public static int getMonth(String time, String pattern)
      获取月份 ( 0 - 11 ) + 1
      参数:
      time - 时间
      pattern - 时间格式
      返回:
      月份
    • getMonth

      public static int getMonth(String time, SimpleDateFormat format)
      获取月份 ( 0 - 11 ) + 1
      参数:
      time - 时间
      format - SimpleDateFormat
      返回:
      月份
    • getDay

      public static int getDay(Calendar calendar)
      获取天数
      参数:
      calendar - Calendar
      返回:
      天数
    • getDay

      public static int getDay()
      获取天数
      返回:
      天数
    • getDay

      public static int getDay(long millis)
      获取天数
      参数:
      millis - 时间毫秒
      返回:
      天数
    • getDay

      public static int getDay(Date date)
      获取天数
      参数:
      date - 日期
      返回:
      天数
    • getDay

      public static int getDay(String time)
      获取天数
      参数:
      time - 时间
      返回:
      天数
    • getDay

      public static int getDay(String time, String pattern)
      获取天数
      参数:
      time - 时间
      pattern - 时间格式
      返回:
      天数
    • getDay

      public static int getDay(String time, SimpleDateFormat format)
      获取天数
      参数:
      time - 时间
      format - SimpleDateFormat
      返回:
      天数
    • getWeek

      public static int getWeek(Calendar calendar)
      获取星期数 ( 1 - 7、日 - 六 )
      参数:
      calendar - Calendar
      返回:
      星期数
    • getWeek

      public static int getWeek()
      获取星期数 ( 1 - 7、日 - 六 )
      返回:
      星期数
    • getWeek

      public static int getWeek(long millis)
      获取星期数 ( 1 - 7、日 - 六 )
      参数:
      millis - 时间毫秒
      返回:
      星期数
    • getWeek

      public static int getWeek(Date date)
      获取星期数 ( 1 - 7、日 - 六 )
      参数:
      date - 日期
      返回:
      星期数
    • getWeek

      public static int getWeek(String time)
      获取星期数 ( 1 - 7、日 - 六 )
      参数:
      time - 时间
      返回:
      星期数
    • getWeek

      public static int getWeek(String time, String pattern)
      获取星期数 ( 1 - 7、日 - 六 )
      参数:
      time - 时间
      pattern - 时间格式
      返回:
      星期数
    • getWeek

      public static int getWeek(String time, SimpleDateFormat format)
      获取星期数 ( 1 - 7、日 - 六 )
      参数:
      time - 时间
      format - SimpleDateFormat
      返回:
      星期数
    • get24Hour

      public static int get24Hour(Calendar calendar)
      获取小时 ( 24 )
      参数:
      calendar - Calendar
      返回:
      小时
    • get24Hour

      public static int get24Hour()
      获取小时 ( 24 )
      返回:
      小时
    • get24Hour

      public static int get24Hour(long millis)
      获取小时 ( 24 )
      参数:
      millis - 时间毫秒
      返回:
      小时
    • get24Hour

      public static int get24Hour(Date date)
      获取小时 ( 24 )
      参数:
      date - 日期
      返回:
      小时
    • get24Hour

      public static int get24Hour(String time)
      获取小时 ( 24 )
      参数:
      time - 时间
      返回:
      小时
    • get24Hour

      public static int get24Hour(String time, String pattern)
      获取小时 ( 24 )
      参数:
      time - 时间
      pattern - 时间格式
      返回:
      小时
    • get24Hour

      public static int get24Hour(String time, SimpleDateFormat format)
      获取小时 ( 24 )
      参数:
      time - 时间
      format - SimpleDateFormat
      返回:
      小时
    • get12Hour

      public static int get12Hour(Calendar calendar)
      获取小时 ( 12 )
      参数:
      calendar - Calendar
      返回:
      小时
    • get12Hour

      public static int get12Hour()
      获取小时 ( 12 )
      返回:
      小时
    • get12Hour

      public static int get12Hour(long millis)
      获取小时 ( 12 )
      参数:
      millis - 时间毫秒
      返回:
      小时
    • get12Hour

      public static int get12Hour(Date date)
      获取小时 ( 12 )
      参数:
      date - 日期
      返回:
      小时
    • get12Hour

      public static int get12Hour(String time)
      获取小时 ( 12 )
      参数:
      time - 时间
      返回:
      小时
    • get12Hour

      public static int get12Hour(String time, String pattern)
      获取小时 ( 12 )
      参数:
      time - 时间
      pattern - 时间格式
      返回:
      小时
    • get12Hour

      public static int get12Hour(String time, SimpleDateFormat format)
      获取小时 ( 12 )
      参数:
      time - 时间
      format - SimpleDateFormat
      返回:
      小时
    • getMinute

      public static int getMinute(Calendar calendar)
      获取分钟
      参数:
      calendar - Calendar
      返回:
      分钟
    • getMinute

      public static int getMinute()
      获取分钟
      返回:
      分钟
    • getMinute

      public static int getMinute(long millis)
      获取分钟
      参数:
      millis - 时间毫秒
      返回:
      分钟
    • getMinute

      public static int getMinute(Date date)
      获取分钟
      参数:
      date - 日期
      返回:
      分钟
    • getMinute

      public static int getMinute(String time)
      获取分钟
      参数:
      time - 时间
      返回:
      分钟
    • getMinute

      public static int getMinute(String time, String pattern)
      获取分钟
      参数:
      time - 时间
      pattern - 时间格式
      返回:
      分钟
    • getMinute

      public static int getMinute(String time, SimpleDateFormat format)
      获取分钟
      参数:
      time - 时间
      format - SimpleDateFormat
      返回:
      分钟
    • getSecond

      public static int getSecond(Calendar calendar)
      获取秒数
      参数:
      calendar - Calendar
      返回:
      秒数
    • getSecond

      public static int getSecond()
      获取秒数
      返回:
      秒数
    • getSecond

      public static int getSecond(long millis)
      获取秒数
      参数:
      millis - 时间毫秒
      返回:
      秒数
    • getSecond

      public static int getSecond(Date date)
      获取秒数
      参数:
      date - 日期
      返回:
      秒数
    • getSecond

      public static int getSecond(String time)
      获取秒数
      参数:
      time - 时间
      返回:
      秒数
    • getSecond

      public static int getSecond(String time, String pattern)
      获取秒数
      参数:
      time - 时间
      pattern - 时间格式
      返回:
      秒数
    • getSecond

      public static int getSecond(String time, SimpleDateFormat format)
      获取秒数
      参数:
      time - 时间
      format - SimpleDateFormat
      返回:
      秒数
    • isAM

      public static boolean isAM(Calendar calendar)
      是否上午
      参数:
      calendar - Calendar
      返回:
      true yes, false no
    • isAM

      public static boolean isAM()
      是否上午
      返回:
      true yes, false no
    • isAM

      public static boolean isAM(long millis)
      是否上午
      参数:
      millis - 时间毫秒
      返回:
      true yes, false no
    • isAM

      public static boolean isAM(Date date)
      是否上午
      参数:
      date - 日期
      返回:
      true yes, false no
    • isAM

      public static boolean isAM(String time)
      是否上午
      参数:
      time - 时间
      返回:
      true yes, false no
    • isAM

      public static boolean isAM(String time, String pattern)
      是否上午
      参数:
      time - 时间
      pattern - 时间格式
      返回:
      true yes, false no
    • isAM

      public static boolean isAM(String time, SimpleDateFormat format)
      是否上午
      参数:
      time - 时间
      format - SimpleDateFormat
      返回:
      true yes, false no
    • isPM

      public static boolean isPM(Calendar calendar)
      是否下午
      参数:
      calendar - Calendar
      返回:
      true yes, false no
    • isPM

      public static boolean isPM()
      是否下午
      返回:
      true yes, false no
    • isPM

      public static boolean isPM(long millis)
      是否下午
      参数:
      millis - 时间毫秒
      返回:
      true yes, false no
    • isPM

      public static boolean isPM(Date date)
      是否下午
      参数:
      date - 日期
      返回:
      true yes, false no
    • isPM

      public static boolean isPM(String time)
      是否下午
      参数:
      time - 时间
      返回:
      true yes, false no
    • isPM

      public static boolean isPM(String time, String pattern)
      是否下午
      参数:
      time - 时间
      pattern - 时间格式
      返回:
      true yes, false no
    • isPM

      public static boolean isPM(String time, SimpleDateFormat format)
      是否下午
      参数:
      time - 时间
      format - SimpleDateFormat
      返回:
      true yes, false no
    • isYear

      public static boolean isYear(Calendar calendar, int year)
      是否对应年份
      参数:
      calendar - Calendar
      year - 待判断年份
      返回:
      true yes, false no
    • isYear

      public static boolean isYear(int year)
      是否对应年份
      参数:
      year - 待判断年份
      返回:
      true yes, false no
    • isYear

      public static boolean isYear(long millis, int year)
      是否对应年份
      参数:
      millis - 时间毫秒
      year - 待判断年份
      返回:
      true yes, false no
    • isYear

      public static boolean isYear(Date date, int year)
      是否对应年份
      参数:
      date - 日期
      year - 待判断年份
      返回:
      true yes, false no
    • isYear

      public static boolean isYear(String time, int year)
      是否对应年份
      参数:
      time - 时间
      year - 待判断年份
      返回:
      true yes, false no
    • isYear

      public static boolean isYear(String time, String pattern, int year)
      是否对应年份
      参数:
      time - 时间
      pattern - 时间格式
      year - 待判断年份
      返回:
      true yes, false no
    • isYear

      public static boolean isYear(String time, SimpleDateFormat format, int year)
      是否对应年份
      参数:
      time - 时间
      format - SimpleDateFormat
      year - 待判断年份
      返回:
      true yes, false no
    • isMonth

      public static boolean isMonth(Calendar calendar, int month)
      是否对应月份
      参数:
      calendar - Calendar
      month - 待判断月份
      返回:
      true yes, false no
    • isMonth

      public static boolean isMonth(int month)
      是否对应月份
      参数:
      month - 待判断月份
      返回:
      true yes, false no
    • isMonth

      public static boolean isMonth(long millis, int month)
      是否对应月份
      参数:
      millis - 时间毫秒
      month - 待判断月份
      返回:
      true yes, false no
    • isMonth

      public static boolean isMonth(Date date, int month)
      是否对应月份
      参数:
      date - 日期
      month - 待判断月份
      返回:
      true yes, false no
    • isMonth

      public static boolean isMonth(String time, int month)
      是否对应月份
      参数:
      time - 时间
      month - 待判断月份
      返回:
      true yes, false no
    • isMonth

      public static boolean isMonth(String time, String pattern, int month)
      是否对应月份
      参数:
      time - 时间
      pattern - 时间格式
      month - 待判断月份
      返回:
      true yes, false no
    • isMonth

      public static boolean isMonth(String time, SimpleDateFormat format, int month)
      是否对应月份
      参数:
      time - 时间
      format - SimpleDateFormat
      month - 待判断月份
      返回:
      true yes, false no
    • isDay

      public static boolean isDay(Calendar calendar, int day)
      是否对应天数
      参数:
      calendar - Calendar
      day - 待判断天数
      返回:
      true yes, false no
    • isDay

      public static boolean isDay(int day)
      是否对应天数
      参数:
      day - 待判断天数
      返回:
      true yes, false no
    • isDay

      public static boolean isDay(long millis, int day)
      是否对应天数
      参数:
      millis - 时间毫秒
      day - 待判断天数
      返回:
      true yes, false no
    • isDay

      public static boolean isDay(Date date, int day)
      是否对应天数
      参数:
      date - 日期
      day - 待判断天数
      返回:
      true yes, false no
    • isDay

      public static boolean isDay(String time, int day)
      是否对应天数
      参数:
      time - 时间
      day - 待判断天数
      返回:
      true yes, false no
    • isDay

      public static boolean isDay(String time, String pattern, int day)
      是否对应天数
      参数:
      time - 时间
      pattern - 时间格式
      day - 待判断天数
      返回:
      true yes, false no
    • isDay

      public static boolean isDay(String time, SimpleDateFormat format, int day)
      是否对应天数
      参数:
      time - 时间
      format - SimpleDateFormat
      day - 待判断天数
      返回:
      true yes, false no
    • isWeek

      public static boolean isWeek(Calendar calendar, int week)
      是否对应星期
      参数:
      calendar - Calendar
      week - 待判断星期
      返回:
      true yes, false no
    • isWeek

      public static boolean isWeek(int week)
      是否对应星期
      参数:
      week - 待判断星期
      返回:
      true yes, false no
    • isWeek

      public static boolean isWeek(long millis, int week)
      是否对应星期
      参数:
      millis - 时间毫秒
      week - 待判断星期
      返回:
      true yes, false no
    • isWeek

      public static boolean isWeek(Date date, int week)
      是否对应星期
      参数:
      date - 日期
      week - 待判断星期
      返回:
      true yes, false no
    • isWeek

      public static boolean isWeek(String time, int week)
      是否对应星期
      参数:
      time - 时间
      week - 待判断星期
      返回:
      true yes, false no
    • isWeek

      public static boolean isWeek(String time, String pattern, int week)
      是否对应星期
      参数:
      time - 时间
      pattern - 时间格式
      week - 待判断星期
      返回:
      true yes, false no
    • isWeek

      public static boolean isWeek(String time, SimpleDateFormat format, int week)
      是否对应星期
      参数:
      time - 时间
      format - SimpleDateFormat
      week - 待判断星期
      返回:
      true yes, false no
    • isHour

      public static boolean isHour(Calendar calendar, int hour)
      是否对应小时
      参数:
      calendar - Calendar
      hour - 待判断小时
      返回:
      true yes, false no
    • isHour

      public static boolean isHour(int hour)
      是否对应小时
      参数:
      hour - 待判断小时
      返回:
      true yes, false no
    • isHour

      public static boolean isHour(long millis, int hour)
      是否对应小时
      参数:
      millis - 时间毫秒
      hour - 待判断小时
      返回:
      true yes, false no
    • isHour

      public static boolean isHour(Date date, int hour)
      是否对应小时
      参数:
      date - 日期
      hour - 待判断小时
      返回:
      true yes, false no
    • isHour

      public static boolean isHour(String time, int hour)
      是否对应小时
      参数:
      time - 时间
      hour - 待判断小时
      返回:
      true yes, false no
    • isHour

      public static boolean isHour(String time, String pattern, int hour)
      是否对应小时
      参数:
      time - 时间
      pattern - 时间格式
      hour - 待判断小时
      返回:
      true yes, false no
    • isHour

      public static boolean isHour(String time, SimpleDateFormat format, int hour)
      是否对应小时
      参数:
      time - 时间
      format - SimpleDateFormat
      hour - 待判断小时
      返回:
      true yes, false no
    • isMinute

      public static boolean isMinute(Calendar calendar, int minute)
      是否对应分钟
      参数:
      calendar - Calendar
      minute - 待判断分钟
      返回:
      true yes, false no
    • isMinute

      public static boolean isMinute(int minute)
      是否对应分钟
      参数:
      minute - 待判断分钟
      返回:
      true yes, false no
    • isMinute

      public static boolean isMinute(long millis, int minute)
      是否对应分钟
      参数:
      millis - 时间毫秒
      minute - 待判断分钟
      返回:
      true yes, false no
    • isMinute

      public static boolean isMinute(Date date, int minute)
      是否对应分钟
      参数:
      date - 日期
      minute - 待判断分钟
      返回:
      true yes, false no
    • isMinute

      public static boolean isMinute(String time, int minute)
      是否对应分钟
      参数:
      time - 时间
      minute - 待判断分钟
      返回:
      true yes, false no
    • isMinute

      public static boolean isMinute(String time, String pattern, int minute)
      是否对应分钟
      参数:
      time - 时间
      pattern - 时间格式
      minute - 待判断分钟
      返回:
      true yes, false no
    • isMinute

      public static boolean isMinute(String time, SimpleDateFormat format, int minute)
      是否对应分钟
      参数:
      time - 时间
      format - SimpleDateFormat
      minute - 待判断分钟
      返回:
      true yes, false no
    • isSecond

      public static boolean isSecond(Calendar calendar, int second)
      是否对应秒数
      参数:
      calendar - Calendar
      second - 待判断秒数
      返回:
      true yes, false no
    • isSecond

      public static boolean isSecond(int second)
      是否对应秒数
      参数:
      second - 待判断秒数
      返回:
      true yes, false no
    • isSecond

      public static boolean isSecond(long millis, int second)
      是否对应秒数
      参数:
      millis - 时间毫秒
      second - 待判断秒数
      返回:
      true yes, false no
    • isSecond

      public static boolean isSecond(Date date, int second)
      是否对应秒数
      参数:
      date - 日期
      second - 待判断秒数
      返回:
      true yes, false no
    • isSecond

      public static boolean isSecond(String time, int second)
      是否对应秒数
      参数:
      time - 时间
      second - 待判断秒数
      返回:
      true yes, false no
    • isSecond

      public static boolean isSecond(String time, String pattern, int second)
      是否对应秒数
      参数:
      time - 时间
      pattern - 时间格式
      second - 待判断秒数
      返回:
      true yes, false no
    • isSecond

      public static boolean isSecond(String time, SimpleDateFormat format, int second)
      是否对应秒数
      参数:
      time - 时间
      format - SimpleDateFormat
      second - 待判断秒数
      返回:
      true yes, false no
    • getSecondMultiple

      public static int getSecondMultiple(long millis)
      获取秒数倍数
      参数:
      millis - 时间毫秒
      返回:
      秒数倍数
    • getMinuteMultiple

      public static int getMinuteMultiple(long millis)
      获取分钟倍数
      参数:
      millis - 时间毫秒
      返回:
      分钟倍数
    • getHourMultiple

      public static int getHourMultiple(long millis)
      获取小时倍数
      参数:
      millis - 时间毫秒
      返回:
      小时倍数
    • getDayMultiple

      public static int getDayMultiple(long millis)
      获取天数倍数
      参数:
      millis - 时间毫秒
      返回:
      天数倍数
    • getWeekMultiple

      public static int getWeekMultiple(long millis)
      获取周数倍数
      参数:
      millis - 时间毫秒
      返回:
      周数倍数
    • getMillisMultiple

      public static int getMillisMultiple(long millis, long unit)
      获取对应单位倍数
      参数:
      millis - 时间毫秒
      unit - 毫秒单位 ( 除数 )
      返回:
      对应单位倍数
    • getTimeDiffByCurrent

      public static long getTimeDiffByCurrent(long millis)
      获取时间差 ( 传入时间 - 当前时间 )
      参数:
      millis - 时间毫秒
      返回:
      与当前时间的时间差 ( 毫秒 )
    • getTimeDiffByCurrent

      public static long getTimeDiffByCurrent(Date date)
      获取时间差 ( 传入时间 - 当前时间 )
      参数:
      date - 日期
      返回:
      与当前时间的时间差 ( 毫秒 )
    • getTimeDiffByCurrent

      public static long getTimeDiffByCurrent(String time)
      获取时间差 ( 传入时间 - 当前时间 )
      参数:
      time - 需要转换的时间
      返回:
      与当前时间的时间差 ( 毫秒 )
    • getTimeDiffByCurrent

      public static long getTimeDiffByCurrent(String time, String pattern)
      获取时间差 ( 传入时间 - 当前时间 )
      参数:
      time - 需要转换的时间
      pattern - 把 time 转换成需要的格式
      返回:
      与当前时间的时间差 ( 毫秒 )
    • getTimeDiffByCurrent

      public static long getTimeDiffByCurrent(String time, SimpleDateFormat format)
      获取时间差 ( 传入时间 - 当前时间 )
      参数:
      time - 需要转换的时间
      format - 把 time 转换成需要的格式
      返回:
      与当前时间的时间差 ( 毫秒 )
    • getTimeDiff

      public static long getTimeDiff(String time1, String time2)
      获取时间差
      参数:
      time1 - 时间
      time2 - 对比时间
      返回:
      时间差 ( 毫秒 )
    • getTimeDiff

      public static long getTimeDiff(String time1, String pattern1, String time2, String pattern2)
      获取时间差
      参数:
      time1 - 时间
      pattern1 - 时间格式
      time2 - 对比时间
      pattern2 - 对比时间格式
      返回:
      时间差 ( 毫秒 )
    • getTimeDiff

      public static long getTimeDiff(String time1, SimpleDateFormat timeFormat1, String time2, SimpleDateFormat timeFormat2)
      获取时间差
      参数:
      time1 - 时间
      timeFormat1 - 时间格式
      time2 - 对比时间
      timeFormat2 - 对比时间格式
      返回:
      时间差 ( 毫秒 )
    • isLeapYear

      public static boolean isLeapYear(int year)
      判断是否闰年
      参数:
      year - 年份
      返回:
      true yes, false no
    • getMonthDayNumberAll

      public static int getMonthDayNumberAll(int year, int month)
      根据年份、月份, 获取对应的天数 ( 完整天数, 无判断是否属于未来日期 )
      参数:
      year - 年份
      month - 月份
      返回:
      指定年份所属的月份的天数
    • getYearMonthNumber

      public static int getYearMonthNumber(int year)
      根据年份, 获取对应的月份
           传入历史、以及未来年份都返回对应年月份
           传入当前年份则返回当前月份
       
      参数:
      year - 年份
      返回:
      内部判断是否相同一年, 不能超过限制未来的月份
    • getMonthDayNumber

      public static int getMonthDayNumber(int year, int month)
      根据年份、月份, 获取对应的天数
           传入历史、以及未来年月份都返回对应年月份的天数
           传入当前年月份则返回当前天数
       
      参数:
      year - 年份
      month - 月份
      返回:
      内部判断是否相同一年、月份, 不能超过限制未来的天数
    • timeAddZero

      public static String timeAddZero(int time)
      时间补 0 处理 ( 小于 10, 则自动补充 0x )
      参数:
      time - 待处理时间
      返回:
      自动补 0 时间字符串
    • timeAddZero

      public static String timeAddZero(int time, boolean appendZero)
      时间补 0 处理 ( 小于 10, 则自动补充 0x )
      参数:
      time - 待处理时间
      appendZero - 是否自动补 0
      返回:
      自动补 0 时间字符串
    • timeAddZero

      public static String timeAddZero(long time)
      时间补 0 处理 ( 小于 10, 则自动补充 0x )
      参数:
      time - 待处理时间
      返回:
      自动补 0 时间字符串
    • timeAddZero

      public static String timeAddZero(long time, boolean appendZero)
      时间补 0 处理 ( 小于 10, 则自动补充 0x )
      参数:
      time - 待处理时间
      appendZero - 是否自动补 0
      返回:
      自动补 0 时间字符串
    • getArrayToHH

      public static String[] getArrayToHH(boolean appendZero)
      生成 HH 按时间排序数组
      参数:
      appendZero - 是否自动补 0
      返回:
      按小时排序的数组
    • getListToHH

      public static List<String> getListToHH(boolean appendZero)
      生成 HH 按时间排序集合
      参数:
      appendZero - 是否自动补 0
      返回:
      按小时排序的集合
    • getArrayToMM

      public static String[] getArrayToMM(boolean appendZero)
      生成 MM 按时间排序数组
      参数:
      appendZero - 是否自动补 0
      返回:
      按分钟排序的数组
    • getListToMM

      public static List<String> getListToMM(boolean appendZero)
      生成 MM 按时间排序集合
      参数:
      appendZero - 是否自动补 0
      返回:
      按分钟排序的集合
    • getArrayToHHMM

      public static String[] getArrayToHHMM(int type, boolean appendZero)
      生成 HH:mm 按间隔时间排序数组
      参数:
      type - 0 = 00:00 - 23:00 = 每 1 小时间隔 1 = 00:00 - 23:45 = 每 15 分钟间隔 2 = 00:00 - 23:30 = 每 30 分钟间隔
      appendZero - 是否自动补 0
      返回:
      指定格式的数组
    • getListToHHMM

      public static List<String> getListToHHMM(int type, boolean appendZero)
      生成 HH:mm 按间隔时间排序集合
      参数:
      type - 0 = 00:00 - 23:00 = 每 1 小时间隔 1 = 00:00 - 23:45 = 每 15 分钟间隔 2 = 00:00 - 23:30 = 每 30 分钟间隔
      appendZero - 是否自动补 0
      返回:
      指定格式的集合
    • getListToHHMMPosition

      public static int getListToHHMMPosition(String time, int type)
      获取 HH:mm 按间隔时间排序的集合中, 指定时间所在索引
      参数:
      time - HH:mm 格式
      type - 0 = 00:00 - 23:00 = 每 1 小时间隔 1 = 00:00 - 23:45 = 每 15 分钟间隔 2 = 00:00 - 23:30 = 每 30 分钟间隔
      返回:
      指定数据, 在对应格式类型内的索引
    • millisToFitTimeSpan

      public static String millisToFitTimeSpan(long millis, int precision, boolean appendZero)
      转换时间
      参数:
      millis - 时间毫秒
      precision - precision = 1, return 天 precision = 2, return 天, 小时 precision = 3, return 天, 小时, 分钟 precision = 4, return 天, 小时, 分钟, 秒 precision = 5, return 天, 小时, 分钟, 秒, 毫秒
      appendZero - 是否自动补 0
      返回:
      转换指定格式的时间字符串
    • millisToTimeArrays

      public static int[] millisToTimeArrays(long millis)
      转换时间为数组
      参数:
      millis - 时间毫秒
      返回:
      int[5] { 天, 小时, 分钟, 秒, 毫秒 }
    • timeConvertByMillis

      public static String timeConvertByMillis(long millis)
      传入时间毫秒, 获取 00:00:00 格式 ( 不处理大于一天 )
      参数:
      millis - 时间毫秒
      返回:
      转换 ( 00:00:00 ) 时间格式字符串
    • timeConvertByMillis

      public static String timeConvertByMillis(long millis, boolean handlerMoreThanDay)
      传入时间毫秒, 获取 00:00:00 格式
           小时:分钟:秒
       
      参数:
      millis - 时间毫秒
      handlerMoreThanDay - 是否处理大于一天的时间
      返回:
      转换 ( 00:00:00 ) 时间格式字符串
    • timeConvertBySecond

      public static String timeConvertBySecond(long second)
      传入时间秒, 获取 00:00:00 格式 ( 不处理大于一天 )
      参数:
      second - 时间 ( 秒 )
      返回:
      转换 ( 00:00:00 ) 时间格式字符串
    • timeConvertBySecond

      public static String timeConvertBySecond(long second, boolean handlerMoreThanDay)
      传入时间秒, 获取 00:00:00 格式
      参数:
      second - 时间 ( 秒 )
      handlerMoreThanDay - 是否处理大于一天的时间
      返回:
      转换 ( 00:00:00 ) 时间格式字符串
    • isInTime

      public static boolean isInTime(long time, long startTime, long endTime)
      判断时间是否在 [startTime, endTime] 区间
      参数:
      time - 待判断时间 ( 毫秒 )
      startTime - 开始时间 ( 毫秒 )
      endTime - 结束时间 ( 毫秒 )
      返回:
      true yes, false no
    • isInTime

      public static boolean isInTime(Date time, Date startTime, Date endTime)
      判断时间是否在 [startTime, endTime] 区间
      参数:
      time - 待判断时间
      startTime - 开始时间
      endTime - 结束时间
      返回:
      true yes, false no
    • isInTimeFormat

      public static boolean isInTimeFormat(String time, String startTime, String endTime, String pattern)
      判断时间是否在 [startTime, endTime] 区间 ( 自定义格式 )
      参数:
      time - 待判断时间
      startTime - 开始时间
      endTime - 结束时间
      pattern - 时间格式
      返回:
      true yes, false no
    • isInTimeFormat

      public static boolean isInTimeFormat(String time, String startTime, String endTime, String pattern, boolean handlerMoreThanDay)
      判断时间是否在 [startTime, endTime] 区间 ( 自定义格式 )
      参数:
      time - 待判断时间
      startTime - 开始时间
      endTime - 结束时间
      pattern - 时间格式
      handlerMoreThanDay - 是否处理大于一天的时间
      返回:
      true yes, false no
    • isInTimeFormat

      public static boolean isInTimeFormat(String time, String startTime, String endTime, SimpleDateFormat format)
      判断时间是否在 [startTime, endTime] 区间 ( 自定义格式 )
      参数:
      time - 待判断时间
      startTime - 开始时间
      endTime - 结束时间
      format - SimpleDateFormat
      返回:
      true yes, false no
    • isInTimeFormat

      public static boolean isInTimeFormat(String time, String startTime, String endTime, SimpleDateFormat format, boolean handlerMoreThanDay)
      判断时间是否在 [startTime, endTime] 区间 ( 自定义格式 )
           handlerMoreThanDay 参数注意事项
           用于 DevFinal.TIME.HHmm_COLONDevFinal.TIME.HHmmss_COLON 判断, 只有该格式判断可传入 true
           其他都用于 false
       
      参数:
      time - 待判断时间
      startTime - 开始时间
      endTime - 结束时间
      format - SimpleDateFormat
      handlerMoreThanDay - 是否处理大于一天的时间
      返回:
      true yes, false no
    • isInTimeHHmm

      public static boolean isInTimeHHmm(String startTime, String endTime)
      判断时间是否在 [startTime, endTime] 区间 ( HHmm 格式 )
      参数:
      startTime - 开始时间
      endTime - 结束时间
      返回:
      true yes, false no
    • isInTimeHHmm

      public static boolean isInTimeHHmm(String startTime, String endTime, boolean handlerMoreThanDay)
      判断时间是否在 [startTime, endTime] 区间 ( HHmm 格式 )
      参数:
      startTime - 开始时间
      endTime - 结束时间
      handlerMoreThanDay - 是否处理大于一天的时间
      返回:
      true yes, false no
    • isInTimeHHmm

      public static boolean isInTimeHHmm(String time, String startTime, String endTime)
      判断时间是否在 [startTime, endTime] 区间 ( HHmm 格式 )
      参数:
      time - 待判断时间
      startTime - 开始时间
      endTime - 结束时间
      返回:
      true yes, false no
    • isInTimeHHmm

      public static boolean isInTimeHHmm(String time, String startTime, String endTime, boolean handlerMoreThanDay)
      判断时间是否在 [startTime, endTime] 区间 ( HHmm 格式 )
      参数:
      time - 待判断时间
      startTime - 开始时间
      endTime - 结束时间
      handlerMoreThanDay - 是否处理大于一天的时间
      返回:
      true yes, false no
    • isInTimeHHmmss

      public static boolean isInTimeHHmmss(String startTime, String endTime)
      判断时间是否在 [startTime, endTime] 区间 ( HHmmss 格式 )
      参数:
      startTime - 开始时间
      endTime - 结束时间
      返回:
      true yes, false no
    • isInTimeHHmmss

      public static boolean isInTimeHHmmss(String startTime, String endTime, boolean handlerMoreThanDay)
      判断时间是否在 [startTime, endTime] 区间 ( HHmmss 格式 )
      参数:
      startTime - 开始时间
      endTime - 结束时间
      handlerMoreThanDay - 是否处理大于一天的时间
      返回:
      true yes, false no
    • isInTimeHHmmss

      public static boolean isInTimeHHmmss(String time, String startTime, String endTime)
      判断时间是否在 [startTime, endTime] 区间 ( HHmmss 格式 )
      参数:
      time - 待判断时间
      startTime - 开始时间
      endTime - 结束时间
      返回:
      true yes, false no
    • isInTimeHHmmss

      public static boolean isInTimeHHmmss(String time, String startTime, String endTime, boolean handlerMoreThanDay)
      判断时间是否在 [startTime, endTime] 区间 ( HHmmss 格式 )
      参数:
      time - 待判断时间
      startTime - 开始时间
      endTime - 结束时间
      handlerMoreThanDay - 是否处理大于一天的时间
      返回:
      true yes, false no
    • getEndTimeDiffHHmm

      public static long getEndTimeDiffHHmm(String endTime)
      获取指定时间距离该时间第二天的指定时段的时间 ( 判断凌晨情况 )
      参数:
      endTime - 结束时间 HH:mm
      返回:
      距离指定结束时间还有多少毫秒
    • getEndTimeDiffHHmm

      public static long getEndTimeDiffHHmm(long startTime, String endTime)
      获取指定时间距离该时间第二天的指定时段的时间 ( 判断凌晨情况 )
      参数:
      startTime - 开始时间
      endTime - 结束时间 HH:mm
      返回:
      距离指定结束时间还有多少毫秒
    • getEndTimeDiff

      public static long getEndTimeDiff(String endTime, String format)
      获取指定时间距离该时间第二天的指定时段的时间差 ( 判断凌晨情况 )
      参数:
      endTime - 结束时间
      format - 格式 如: HH:mm
      返回:
      距离指定结束时间还有多少毫秒
    • getEndTimeDiff

      public static long getEndTimeDiff(long startTime, String endTime, String format)
      获取指定时间距离该时间第二天的指定时段的时间差 ( 判断凌晨情况 )
           如当前时间 2018-12-07 15:27:23, 判断距离 14:39:20 (endTime) 有多久
           如果过了这个时间段, 则返回 2018-12-08 14:39:20 ( 明天的这个时间段时间 )
           如果没有过这个时间段 ( 如: 17:39:20) 则返回当天时间段 2018-12-07 17:39:20 (2018-12-07 + endTime)
       
      参数:
      startTime - 开始时间
      endTime - 结束时间
      format - 格式 如: HH:mm
      返回:
      距离指定结束时间还有多少毫秒
    • getZodiac

      public static String getZodiac(int year)
      获取生肖
      参数:
      year - 年份
      返回:
      生肖
    • getConstellation

      public static String getConstellation(int month, int day)
      获取星座
      参数:
      month - 月份
      day - 天数
      返回:
      星座
    • getConstellationDate

      public static String getConstellationDate(int month, int day)
      获取星座日期
      参数:
      month - 月份
      day - 天数
      返回:
      星座日期