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 对比时间大小 字符类型
最新推荐文章于 2024-07-24 04:39:25 发布