54c7374b220aab9d4d542a9bc5865a960b0f7d27
[mir.git] / source / mir / util / DateToMapAdapter.java
1 package mir.util;
2
3 import java.util.*;
4 import java.text.*;
5
6 import mir.misc.*;
7
8 public class DateToMapAdapter extends AbstractMap {
9   Date date;
10
11   public DateToMapAdapter(Date aDate) {
12     date = aDate;
13   }
14
15   public Object get(Object aKey) {
16     if (aKey instanceof String) {
17       try {
18         // ML: quick fix to allow for the dc encoding now...
19         if (((String) aKey).equals("dc")) {
20           return StringUtil.date2w3DateTime(new GregorianCalendar());
21         }
22         else
23           return new SimpleDateFormat((String) aKey).format(date);
24       }
25       catch (Throwable t) {
26         throw new RuntimeException( "Can't format date with format " + (String) aKey + ": " + t.getMessage());
27       }
28     }
29     else return null;
30   }
31
32   public Set entrySet() {
33     return new HashSet();
34   }
35 }