I have a hashmap:
Map dateEvent = new HashMap(); where key is a date and time and value is a string.
I fill collection with data where date is in format dd.MM.yyyy HH:mm.
How I can get all keys with date based on this format: dd.MM.yyyy?
I have a hashmap: Map dateEvent = new HashMap(); where key is a date
Share
This code will do the trick:
The important thing here is that all dates are converted to a String with format “dd.MM.yyyy” before comparing, so any differences in hour/minute/second still match if the day is the same.
This code also demonstrates the best way (IMHO) to iterate over a map.