| | |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | /** |
| | | * 获取未来时间 |
| | | * @param second 秒 |
| | | * @return |
| | | */ |
| | | public static Date getFutureDate(int second){ |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.SECOND,second); |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | public static String getFormatTimeString(Date date, String pattern) |
| | | { |
| | | SimpleDateFormat sDateFormat = getDateFormat(pattern); |
| | |
| | | return getDateFromString(str, pattern).getTime(); |
| | | } |
| | | |
| | | /** |
| | | * 校验字符串是否可以格式化为时间 |
| | | * @param str |
| | | * @param pattern |
| | | * @return |
| | | */ |
| | | public static boolean judgeDate(String str,String pattern){ |
| | | try{ |
| | | dateString2Long(str,pattern); |
| | | }catch (Exception e){ |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | public static String longToDateStringDefault(long time) |
| | | { |
| | | return getFormatTimeString(new Date(time), "yyyyMMddHHmmss"); |