开发者

How to get mindate value from collection of hashmap?

开发者 https://www.devze.com 2023-03-30 06:45 出处:网络
i have following code snippe开发者_如何学Cts ArrayList col = [{name =\"ddd\",date =10/08/2011},{name =\"xxxx\",date =15/08/2011},....]

i have following code snippe开发者_如何学Cts

ArrayList col = [{name ="ddd",date =10/08/2011},{name ="xxxx",date =15/08/2011},....]

i have one arraylist that contain list of hashmap as above . In each hashmap there is key called date. Now, i want to get mindate from all dates present in list of hashmap.

for example in above collection i should get 10/08/2011

how to do that ? Plz help me

Thanks In Adavance


  • Start with a null result.
  • Iterate through the list.
  • get the date of the current map. If the result is null or if the result is bigger than the date of the current map, set the result to the date of the current map.
  • after the loop, return the result

Dates can be compared with date1.compareTo(date2), since java.util.Date implements Comparable.

If your dates are in fact strings representing dates, parse the string using SimpleDateFormat.

The javadoc is here: http://download.oracle.com/javase/6/docs/api/index.html

0

精彩评论

暂无评论...
验证码 换一张
取 消