My application uses an API that accepts only a Map<String, String>. Therefore, all objects must be converted to this form before they can be passed to the API.
This is quite trivial for simple classes like Boolean, BigDecimal etc. But it is proving somewhat problematic for converting a Calendar object.
I am not overly familiar with all the nuances of Calendars/Dates etc in Java so would appreciate some advice on converting my Calendar to a String and then back again.
When my application receives a request, it already has the Calendar constructed. It must then convert this to a String (1), pass it through the API (2), and then convert it back to a Calendar (3) on the other side.
So I am in control of 1 and 3, but not 2.
Based on this, what is the easiest way to convert to and then from a String?
Thanks
Probably the best thing to do is use
Calendar.getTimeInMillis(), store it as aStringversion of thatlongvalue, and thenCalendar.getInstance().setTimeInMillis(Long.parseLong(Map.get(strIndex)))to get the Calendar back.