类 CodeDateTimeUtils

java.lang.Object
cloud.opencode.base.util.CodeDateTimeUtils

public final class CodeDateTimeUtils extends Object
版本:
v1.0.0
作者:
Jon So, e-mail: ijonso123@gmail.com url: Jon's blog url: project github
  • 字段详细资料

    • DATE_PATTERN

      public static final String DATE_PATTERN
      yyyy-MM-dd
      另请参阅:
    • DATE_TIME_PATTERN

      public static final String DATE_TIME_PATTERN
      yyyy-MM-dd HH:mm:ss
      另请参阅:
    • DATE_TIME_STRING_PATTERN

      public static final String DATE_TIME_STRING_PATTERN
      yyyyMMddHHmmss
      另请参阅:
  • 构造器详细资料

    • CodeDateTimeUtils

      private CodeDateTimeUtils()
  • 方法详细资料

    • getMilli

      public static long getMilli()
      get milliseconds now(Shanghai)
      返回:
      long
    • getSecond

      public static long getSecond()
      get seconds now(Shanghai)
      返回:
      long
    • getMilli

      public static long getMilli(LocalDateTime time)
      get milliseconds by local datetime(Shanghai)
      参数:
      time - LocalDateTime
      返回:
      long
    • getSecond

      public static long getSecond(LocalDateTime time)
      get seconds by local datetime(Shanghai)
      参数:
      time - LocalDateTime
      返回:
      long
    • getCurrentTimeStamp

      public static String getCurrentTimeStamp()
      get current time timestamp by local datetime(Shanghai)
      返回:
      String
    • format

      public static String format(Date date)
      yyyy-MM-dd
      参数:
      date - date
      返回:
      String
    • format

      public static String format(Date date, String pattern)
      return by format
      参数:
      date - date
      pattern - String pattern
      返回:
      String
    • stringToDate

      public static Date stringToDate(String strDate, String pattern)
      string convert date
      参数:
      strDate - String date
      pattern - String pattern
      返回:
      date
    • getWeekStartAndEnd

      public static Date[] getWeekStartAndEnd(int week)
      get the begin date and end date from week number
      参数:
      week - week 0= this week,-1= last week,-2= two weeks ago,1= next week,2= week after next
      返回:
      date[0]= begin date、date[1]= end date
    • addDateSeconds

      public static Date addDateSeconds(Date date, int seconds)
      add or minus second
      参数:
      date - date
      seconds - second is number, it can be negative number
      返回:
      date
    • addDateMinutes

      public static Date addDateMinutes(Date date, int minutes)
      add or minus minute
      参数:
      date - date
      minutes - minute is number, it can be negative number
      返回:
      date
    • addDateHours

      public static Date addDateHours(Date date, int hours)
      add or minus hour
      参数:
      date - date
      hours - hour is number, it can be negative number
      返回:
      date
    • addDateDays

      public static Date addDateDays(Date date, int days)
      add or minus day
      参数:
      date - date
      days - day is number, it can be negative number
      返回:
      date
    • addDateWeeks

      public static Date addDateWeeks(Date date, int weeks)
      add or minus week
      参数:
      date - date
      weeks - week is number, it can be negative number
      返回:
      date
    • addDateMonths

      public static Date addDateMonths(Date date, int months)
      add or minus month
      参数:
      date - date
      months - month is number, it can be negative number
      返回:
      date
    • addDateYears

      public static Date addDateYears(Date date, int years)
      add or minus year
      参数:
      date - date
      years - year is number,it can be negative number
      返回:
      date
    • getRFC3339

      public static String getRFC3339(Date date)
      convert time to RFC3339
      参数:
      date - date
      返回:
      2021-01-29T17:05:58+08:00
    • getRFC3339

      public static String getRFC3339(String datetime)
      convert time to RFC3339 format
      参数:
      datetime - format:2021-01-29 17:05:58
      返回:
      datetime string