public static boolean contrastTimeSize(String maxTime,String minTime,String dataType){ SimpleDateFormat format = new SimpleDateFormat(dataType); try { Calendar calendar = Calendar.getInstance(); calendar.setTime(format.parse(maxTime)); int planYear = calendar.get(Calendar.YEAR); int planMonth = calendar.get(Calendar.MONTH) + 1; calendar.setTime(format.parse(minTime)); int testYear = calendar.get(Calendar.YEAR); int testMonth = calendar.get(Calendar.MONTH) + 1; double startTime = new BigDecimal(planMonth / (double) 12).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() + planYear; double endTime = new BigDecimal(testMonth / (double) 12).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() + testYear; if(startTime > endTime){ return false; } } catch (ParseException e) { e.printStackTrace(); } return true; }
Java 对比时间大小 字符类型
猜你喜欢
转载自blog.csdn.net/qq_37511501/article/details/80193126
今日推荐
周排行