| | |
| | | * 日期格式(yyyy-MM-dd HH) |
| | | * */ |
| | | public static final String yyyy_MM_dd_HH_EN = "yyyy-MM-dd HH"; |
| | | /* |
| | | * 日期格式(MM-dd) |
| | | * */ |
| | | public static final String MM_dd_EN = "MM-dd"; |
| | | |
| | | /* |
| | | * Date类toString格式 |
| | |
| | | return new Date(); |
| | | } |
| | | |
| | | |
| | | |
| | | public static String getAfterNDays(Date date, int n, String formateStr) { |
| | | SimpleDateFormat sdf = new SimpleDateFormat(formateStr); |
| | | Calendar calendar = new GregorianCalendar(); |
| | |
| | | int year = cal.get(Calendar.YEAR); |
| | | return year == currentYear; |
| | | } |
| | | |
| | | /* |
| | | * 判断日期是否为本月 |
| | | * */ |
| | | public static boolean isCurrentMonth(Date date) { |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(new Date()); |
| | | int currentYear = cal.get(Calendar.MONTH); |
| | | cal.setTime(date); |
| | | int year = cal.get(Calendar.MONTH); |
| | | return year == currentYear; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取当前月的最后一天 |
| | |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | //加减年份 |
| | | public static Date addYears(Date date, int years) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | calendar.add(Calendar.YEAR, years); |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | /** |
| | | * <p> |
| | | * Title: getDays |