LANGUAGE/Java & Groovy 2016. 2. 26. 22:14

///// Java (자바)




///// Comparing Dates (날짜 비교)

boolean isValidDate(String startDt, String endDt){

// startDt <= someDt <= endDt
DateFormat dtf =
new SimpleDateFormat("yyyy-MM-dd")
Date someDt =
new Date() // Now
Date fromDt = dtf.parse(startDt)
Date toDt = dtf.parse(endDt)
return (someDt.after(fromDt) && someDt.before(toDt+1))


}


isValidDate('1990-01-01', '9999-01-01')



///// 참조 (Reference)

How to compare dates in Java?:

http://stackoverflow.com/questions/2592501/how-to-compare-dates-in-java


Parse String to Date with Different Format in Java:

http://stackoverflow.com/questions/882420/parse-string-to-date-with-different-format-in-java