| | |
| | | |
| | | /** |
| | | * 字符串转date |
| | | * |
| | | * |
| | | * @param date |
| | | * 时间戳 |
| | | * @param format |
| | |
| | | |
| | | /** |
| | | * 字符串转date |
| | | * |
| | | * |
| | | * @param date |
| | | * 时间戳 |
| | | * @return 时间 |
| | |
| | | |
| | | /** |
| | | * 字符串转date |
| | | * |
| | | * |
| | | * @param date |
| | | * 时间戳 |
| | | * @return 时间 |
| | |
| | | |
| | | /** |
| | | * 获取当前时间 |
| | | * |
| | | * |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 返回当前事件的时间戳 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public static Long getCurrentDateTimeStamp() { |
| | |
| | | |
| | | /** |
| | | * 获取当前时间字符串,格式为yyyy-MM-dd HH:mm:ss |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getCurrentDateStr() { |
| | |
| | | |
| | | /** |
| | | * 获取当前时间字符串,格式为yyyyMMdd |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getCurrentDateString() { |
| | |
| | | |
| | | /** |
| | | * 获取当前时间字符串,格式为yyyy-MM-dd |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getCurrentDateStrymd() { |
| | |
| | | |
| | | /** |
| | | * 获取当前时间long值 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public static long getCurrentDataLong() { |
| | |
| | | |
| | | /** |
| | | * 获取当前时间 |
| | | * |
| | | * |
| | | * @param format |
| | | * @return |
| | | * @throws Exception |
| | |
| | | |
| | | /** |
| | | * 对日期进行加法操作 |
| | | * |
| | | * |
| | | * @param date |
| | | * @param hours |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 对日期的分钟进行加法操作 |
| | | * |
| | | * |
| | | * @param date |
| | | * @param minutes |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 计算两个日期先差多少秒 |
| | | * |
| | | * |
| | | * @param pre |
| | | * 前一个日期 |
| | | * @param after |
| | |
| | | |
| | | /** |
| | | * 计算两个时间相差的天数 |
| | | * |
| | | * |
| | | * @param stardate |
| | | * @param enddate |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 结束时间与当前时间计算相差的月数 |
| | | * |
| | | * |
| | | * @param enddate |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 获取某个时间段之前的时间点 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getSomeTimeStapStr(String sign) { |
| | |
| | | |
| | | /** |
| | | * 获取失效时间点(在什么时间失效) |
| | | * |
| | | * |
| | | * @param minutes |
| | | * 有效分钟数 |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 获取当前年份 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getCurrentYear() { |
| | |
| | | |
| | | /** |
| | | * 获取当前月份 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getCurrentMonth() { |
| | |
| | | |
| | | /** |
| | | * 获取无符号的当前时间 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getCurrentDateStrNoSignal() { |
| | |
| | | |
| | | /** |
| | | * 获取前几个小时的时间 |
| | | * |
| | | * |
| | | * @param hours |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 小时取整 |
| | | * |
| | | * |
| | | * @param date |
| | | * @param hour |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 分钟取整 以十分钟为单位 ,去除尾端,加上 参数 46->40+minutes*10 |
| | | * |
| | | * |
| | | * @param date |
| | | * @param minutes |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 天数取整 |
| | | * |
| | | * |
| | | * @param date |
| | | * @param day |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 日期相加减 |
| | | * |
| | | * |
| | | * @param time |
| | | * 时间字符串 yyyy-MM-dd HH:mm:ss |
| | | * @param num |
| | |
| | | |
| | | /** |
| | | * 获取当前月第一天 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public static Date getFirstDayOfMonth() { |
| | |
| | | |
| | | /** |
| | | * 获取当前年月的第一天时间 |
| | | * |
| | | * |
| | | * @param year |
| | | * 年份 |
| | | * @param month |
| | |
| | | |
| | | /** |
| | | * 获取当前年月的最后一天时间 |
| | | * |
| | | * |
| | | * @param year |
| | | * 年份 |
| | | * @param month |
| | |
| | | |
| | | /** |
| | | * date2比date1多的天数 |
| | | * |
| | | * |
| | | * @param date1 |
| | | * @param date2 |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 获取当前月第一天 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getFirstDayOfMonthString() { |
| | |
| | | |
| | | /** |
| | | * 获取当前月最后一天 |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getLastDayOfMonthString() { |
| | |
| | | |
| | | /** |
| | | * 获取当前时间(年月日) |
| | | * |
| | | * |
| | | * @return |
| | | */ |
| | | public static String getDayOfMonthString() { |
| | |
| | | } |
| | | return dates; |
| | | } |
| | | |
| | | /** |
| | | * 获取上月最后一天时间 |
| | | * @return 上月最后一天时间 |
| | | */ |
| | | public static String getOldMonthLastDay(){ |
| | | Calendar calendar=Calendar.getInstance(); |
| | | int month=calendar.get(Calendar.MONTH); |
| | | calendar.set(Calendar.MONTH, month-1); |
| | | calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); |
| | | return format_yyymmdd.format(calendar.getTime()); |
| | | } |
| | | |
| | | /** |
| | | * 获取上月第一天时间 |
| | | * @return 上月第一天时间 |
| | | */ |
| | | public static String getOldMonthFirstDay(){ |
| | | Calendar calendar=Calendar.getInstance(); |
| | | calendar.add(Calendar.MONTH, -1); |
| | | calendar.set(Calendar.DAY_OF_MONTH, 1); |
| | | return format_yyymmdd.format(calendar.getTime()); |
| | | } |
| | | } |