I want to get weekdays for common time sets from the following hashmap
The thing you need to do is commonly called "grouping", i.e. you iterate over a given dataset, take one property (the time in your case) and collect the entries with the same property in a useful structure.

Fortunately, java (8+) already can do this for you by streaming through the map entries and grouping them all automagically:

    Map&lt;String, List&lt;Map.Entry&lt;String, String&gt;&gt;&gt; grouped = days.entrySet().stream()
        .collect(Collectors.groupingBy(Map.Entry::getValue));


OK, the data-structure looks a little wierd here, because your list consists of map-entries, but this was the main work. If you print this result, you already get (format added manually):

{
     9-4=[TUE=9-4],
     9-5=[MON=9-5, WED=9-5, THU=9-5, FRI=9-5],
     Closed=[SAT=Closed, SUN=Closed]
}


... which is exactly what you need from a data perspective. Using a further iteration over this map which uses the time as a key and the old map's entries as values to format the respective output should be quite trivial.

BTW: to keep the order of the days, you should use a LinkedHashMap instead of a HashMap.