| | |
| | | public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss"; |
| | | |
| | | public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; |
| | | public static String HH_MM_SS = "HH:mm:ss"; |
| | | |
| | | private static String[] parsePatterns = { |
| | | "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", |
| | |
| | | ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault()); |
| | | return Date.from(zdt.toInstant()); |
| | | } |
| | | |
| | | /*判断时间是否在时间内*/ |
| | | public static boolean TimeCompare(String startT,String endT) |
| | | { |
| | | LocalTime startTime = LocalTime.parse(startT); // 开始时间 |
| | | LocalTime endTime = LocalTime.parse(endT); // 结束时间 |
| | | LocalTime currentTime = LocalTime.now(); // 当前时间 |
| | | // 判断当前时间是否在时间区间内 |
| | | if (currentTime.isAfter(startTime) && currentTime.isBefore(endTime)) { |
| | | // System.out.println("当前时间在时间区间内"); |
| | | return true; |
| | | } else { |
| | | // System.out.println("当前时间不在时间区间内"); |
| | | return false; |
| | | } |
| | | } |
| | | public static boolean TimeCompare(Date startT,Date endT) |
| | | { |
| | | Date current=new Date(); |
| | | // 判断当前时间是否在时间区间内 |
| | | if (current.after(startT) && current.before(endT)) { |
| | | // System.out.println("当前时间在时间区间内"); |
| | | return true; |
| | | } else { |
| | | // System.out.println("当前时间不在时间区间内"); |
| | | return false; |
| | | } |
| | | } |
| | | } |