类 DateUtil

java.lang.Object
cn.warpin.core.util.DateUtil

public class DateUtil extends Object
  • 字段详细资料

  • 构造器详细资料

    • DateUtil

      public DateUtil()
  • 方法详细资料

    • sqlDateToUtilDate

      public static Date sqlDateToUtilDate(Date sqlDate)
      sql.Date转util.Date
      参数:
      sqlDate -
      返回:
    • utilDateToSqlDate

      public static Date utilDateToSqlDate(Date utilDate)
      util.Date转sql.Date
      参数:
      utilDate -
      返回:
    • dateToString

      public static String dateToString(Date date, String formatType)
    • sql_dateToString

      public static String sql_dateToString(Date date, String formatType)
    • longToString

      public static String longToString(long currentTime, String formatType)
    • stringToDate

      public static Date stringToDate(String strTime, String formatType)
    • stringToSqlDate

      public static Date stringToSqlDate(String strTime, String formatType)
    • stringToTimestamp

      public static Timestamp stringToTimestamp(String strTime)
    • timestampToString

      public static String timestampToString(Timestamp timestamp, String formatType)
    • longToDate

      public static Date longToDate(long currentTime, String formatType)
    • stringToLong

      public static long stringToLong(String strTime, String formatType)
    • dateToLong

      public static long dateToLong(Date date)
    • getDateZero

      public static Long getDateZero(int hours)
    • getWeekNum

      public static int getWeekNum(Date startDate, Date checkDate)
    • dayOfWeek

      public static int dayOfWeek(Date date)
    • compareDate

      public static boolean compareDate(Date targetDate, Date baseDate)
      判断比较时间到目标时间是否超过一天
      参数:
      targetDate - 目标时间
      baseDate - 基础时间
      返回:
      超过返回true,没超过返回false
    • timePlusFmt

      public static String timePlusFmt(Date date)
      时分秒日期格式转当日时间戳
      参数:
      time -
      返回:
      抛出:
      ParseException
    • timePlusFmt

      public static String timePlusFmt(String time)
      时分秒字符串转当日时间戳
      参数:
      time -
      返回:
    • isYeaterday

      public static boolean isYeaterday(Date oldTime, Date newTime) throws Exception
      判断是否是昨天
      参数:
      oldTime - 较小的时间
      newTime - 较大的时间 (如果为空 默认当前时间 ,表示和当前时间相比)
      返回:
      -1 :同一天. 0:昨天 . 1 :至少是前天.
      抛出:
      Exception
    • calTimeRageToDays

      public static Integer calTimeRageToDays(Long beginTime, Long endTime)
      计算两个时间中间的天数
      参数:
      beginTime -
      endTime -
      返回:
      抛出:
      Exception
    • getCalendarNum

      public static String getCalendarNum(String dateStr, Integer calendarType)
      获取日期的年月日
      参数:
      dateStr - 传入的时间,如果不传,则取当前时间
      calendarType - Calendar类的常量
      返回:
    • getStartOfWeek

      public static Timestamp getStartOfWeek()
      获取本周第一天日期
      返回:
    • getOffsetTime

      public static String getOffsetTime(Long time)
      获取便宜时间字符串
      参数:
      time -
      返回:
    • getDayStartTime

      public static Timestamp getDayStartTime(String dateStr)
      获取当天的起始时间
      返回:
    • getDayEndTime

      public static Timestamp getDayEndTime(String dateStr)
      获取当天的结束时间
      返回:
    • main

      public static void main(String[] args)