| | |
| | | package com.java110.common.util; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前月 |
| | | * @return |
| | | */ |
| | | public static int getCurrentMonth(){ |
| | | Calendar calendar = Calendar.getInstance(); |
| | | return calendar.get(Calendar.MONTH)+1; |
| | | } |
| | | |
| | | public static Date getLastDate() throws ParseException { |
| | | return getDateFromString("3000-01-01",DATE_FORMATE_STRING_B); |
| | | } |
| | | |
| | | /** |
| | | * 转TimeStamp |
| | | * @param date |
| | | * @return |
| | | */ |
| | | public static Timestamp getTimestamp(Date date){ |
| | | Timestamp timestamp = new Timestamp(date.getTime()); |
| | | return timestamp; |
| | | } |
| | | /** |
| | | * 获取未来时间 |
| | | * @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); |