类 DateUtils

java.lang.Object
com.walker.infrastructure.utils.DateUtils

public abstract class DateUtils extends Object
处理日期格式以及转换的工具类
作者:
shikeying
  • 字段详细资料

  • 构造器详细资料

    • DateUtils

      public DateUtils()
  • 方法详细资料

    • getLastYearStartDay

      public static long getLastYearStartDay()
      返回上年份第一天时间值
      返回:
      如:20230101000000
    • getLastYearEndDay

      public static final long getLastYearEndDay()
    • getCurrentYearStartDay

      public static final long getCurrentYearStartDay()
      返回当前年份第一天时间值
      返回:
      如:20230101000000
    • getCurrentYearEndDay

      public static final long getCurrentYearEndDay()
    • getLastMonthStartDay

      public static final long getLastMonthStartDay()
      返回上月第一天的时间值
      返回:
      如:20230601000000
    • getLastMonthEndDay

      public static final long getLastMonthEndDay()
    • getCurrentMonthStartDay

      public static final long getCurrentMonthStartDay()
      返回当前月份第一天的时间值
      返回:
      如:20230601000000
    • getCurrentMonthEndDay

      public static final long getCurrentMonthEndDay()
    • getCurrentWeekStartDay

      public static long getCurrentWeekStartDay()
      获得本周第一天,格式:20230602000000
    • toMillSeconds

      public static final long toMillSeconds(long showTimeLong)
      把数值可视化时间转换成毫秒值,如:20140829102501 --> 毫秒值
      参数:
      showTimeLong -
      返回:
    • toShowDate

      public static final String toShowDate(int date)
      把8位整形数值,转换成日期显示格式。

      如:20140829 --> 2014-08-29
      参数:
      date -
      返回:
    • toShowDate

      public static final String toShowDate(long date)
      把14位整形数值,转换成日期显示格式。

      如:20140829102501 --> 2014-08-29 10:25:01
      参数:
      date -
      返回:
    • toIntegerDate

      public static final int toIntegerDate(String showDate)
      把显示的日期格式转化成整型值。

      如:2014-08-29 --> 20140829
      参数:
      showDate -
      返回:
    • toIntegerDateTime

      public static final int toIntegerDateTime(String showDate)
    • toLongDateTime

      public static final long toLongDateTime(String showDate)
      把显示的日期格式转化成整型值。

      如:2014-08-29 --> 20140829000000
      参数:
      showDate -
      返回:
    • getCurrentMonthFirstDayEarly

      public static final long getCurrentMonthFirstDayEarly()
      返回当月第一天最早的时间毫秒数,如:2014-03-01 00:00:00 毫秒数
      返回:
    • getTodayLongEarly

      public static final long getTodayLongEarly()
      返回当天最早的毫秒数,即:当天00:00:00的毫秒值
      返回:
    • getTodayLongLate

      public static final long getTodayLongLate()
      返回当天最晚的毫秒数,即:当天23:59:59的毫秒值
      返回:
    • getTodayForHuman

      public static final String getTodayForHuman()
      返回当天日期,如:2013-11-21
      返回:
    • getDateTimeForHuman

      public static final String getDateTimeForHuman(long millis)
      把毫秒值格式化为可以识别的日期字符串,如:2013-11-21 12:33:09
      参数:
      millis -
      返回:
    • getDateForHuman

      public static final String getDateForHuman(long millis)
      把毫秒值格式化为可以识别的日期字符串,如:2013-11-21
      参数:
      millis -
      返回:
    • getDateNumber

      public static final long getDateNumber(long millis)
      返回给定毫秒数对应的日期数值,如:20131121
      参数:
      millis -
      返回:
    • getDateTimeNumber

      public static final long getDateTimeNumber(long millis)
      返回给定毫秒数对应的日期数值,如:20201220120130
      参数:
      millis -
      返回:
    • getDateTimeNumber

      public static final long getDateTimeNumber()
      返回当前日期数值,如:20201220120130
      返回:
    • getDateTimeNumber

      public static final long getDateTimeNumber(String showDateTime)
      返回给定毫秒数对应的日期数值,如:20201220120130
      参数:
      showDateTime - 如:2020-12-20 12:01:30
      返回:
    • getDateLongLate

      public static final long getDateLongLate(String showDate)
      返回给定日期,最晚的毫秒值。

      如:2013-11-21,系统会返回 2013-11-21 23:59:59 的毫秒值
      参数:
      showDate - 2013-11-21
      返回:
    • getDateLongEarly

      public static final long getDateLongEarly(String showDate)
      返回给定日期,最早的毫秒值。

      如:2013-11-21,系统会返回 2013-11-21 00:00:00 的毫秒值
      参数:
      showDate - 2013-11-21
      返回:
    • getDateLong

      public static final long getDateLong(String showDateTime)
      返回字符串日期的毫秒时间值。
      参数:
      showDateTime - 可以是:2013-11-21 or 2013-11-21 11:21:15
      返回:
    • getDate

      public static final Date getDate(String showDate)
      把字符串日期格式化成java.util.Date对象。

      支持日期和时间两种格式,必须是以下形式:
       
    • 2013-11-21
    • 2013-11-21 11:21:15
    • 参数:
      showDate - 输入的日期字符串,必须用'-'作为分隔符。如:2013-11-21
      返回:
    • getYearMonthValue

      public static String getYearMonthValue(String showDateOrTime)
      输入日期(或时间)字符串,返回年月字符串。

      如:2016-07-30 or 2016-07-30 10:01:36 ---> 201607
      参数:
      showDateOrTime -
      返回:
    • getYearMonthCurrentValue

      public static String getYearMonthCurrentValue()
      返回当前年月字符串,如:201607
      返回:
    • getDateTimeSecondForShow

      public static String getDateTimeSecondForShow(long millis)
      返回显示时间字符串,如:20161202152028
      参数:
      millis - 输入毫秒值
      返回:
    • getDateTimeSecondForShow

      public static String getDateTimeSecondForShow()
    • getAfterLongTime

      public static long getAfterLongTime(long oldTime, int dayNum)
      说明:返回指定时间之后的时间,可正可负,例如:给定20071201000000,减10天,得到新的日期 作者:时克英 时间:12 7, 2007
    • getShowDateTimeAfterDays

      public static String getShowDateTimeAfterDays(int daysNumber)
      返回指定天数之后的日期时间,如:2018-03-29 13:57:01
      参数:
      daysNumber - 增加的天数,可为负值表示之前几天
      返回:
    • getYearMonthDayArray

      public static int[] getYearMonthDayArray(int afterDay)
      返回当前年月日,可以增减天数
      参数:
      afterDay - 增加的天数(可为负值表示递减)
      返回:
    • getShowDateAfterDays

      public static String getShowDateAfterDays(int daysNumber)
      返回指定天数之后的日期时间,如:2018-03-29
      参数:
      daysNumber - 增加的天数,可为负值表示之前几天
      返回:
    • getNextDay

      public static int[] getNextDay(int year, int month, int dayOfMonth, int afterDayNum)
      返回给定日期的后续几天的日期值
      参数:
      year - 当前年份,如:2019
      month - 当前月份,如:1月
      dayOfMonth - 当前日期,如:2号
      afterDayNum - 今后几天
      返回:
      返回数组,3个值,如:[2019,1,2]
    • getCurrentWeekdayValue

      public static int getCurrentWeekdayValue()
      返回当前日期是星期几
      返回:
      1~7
    • getCurrentYear

      public static String getCurrentYear()
      返回当前年份
      返回:
    • getCurrentYearInteger

      public static int getCurrentYearInteger()
    • getCurrentYearMonthForHuman

      public static String getCurrentYearMonthForHuman()
      返回当前年月信息,格式:2020-12
      返回:
    • getCurrentHour

      public static int getCurrentHour()
    • getCurrentMinute

      public static int getCurrentMinute()
    • getCurrentHourMinute

      public static int[] getCurrentHourMinute(int afterMinutes)
      返回当前小时:分钟
      参数:
      afterMinutes - 可以增加分钟(正负都可)
      返回:
    • getCurrentYearMonthDay

      public static int[] getCurrentYearMonthDay()
      返回当前年月日,放在数组中
      返回:
    • getCurrentYearMonthDayHourMinute

      public static int[] getCurrentYearMonthDayHourMinute()
    • getCurrentYearMonthDayHourMinute

      public static int[] getCurrentYearMonthDayHourMinute(int monthAdd, int dayAdd, int hourAdd, int minuteAdd)
    • getCurrentYearMonthDayHourMinuteSecond

      public static int[] getCurrentYearMonthDayHourMinuteSecond(int addSeconds)
      提供一个增加的秒数,计算之后的时间。
      参数:
      addSeconds - 要增加的秒数
      返回:
    • getCurrentYearMonthDay

      public static int[] getCurrentYearMonthDay(int afterDays)
    • main

      public static void main(String[] args) throws Exception
      参数:
      args -
      抛出:
      Exception