I am receiving date/time strings from a website that seem to have a variable number of digits for the milliseconds value.

Sample:

> 
> 2013-08-15T06:21:49.35054+01:00
> 
> 
> 2013-08-15T06:21:49.350546+01:00
> 
> 
> 2013-08-15T06:21:49+01:00
> 
> 
> 

Currently I use:

```
static final Map<Integer,DateTimeFormatter> parsers = new HashMap<Integer,DateTimeFormatter>();
static {
  parsers.put("2013-07-23T22:44:00+01:00".length(),
              DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZ"));
  parsers.put("2013-07-27T18:00:59.9+01:00".length(),
              DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SZ"));
  parsers.put("2013-07-27T18:00:59.99+01:00".length(),
              DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSZ"));
  parsers.put("2013-07-27T18:00:59.999+01:00".length(),
              DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));
  parsers.put("2013-07-27T18:00:59.9999+01:00".length(),
              DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSZ"));
  parsers.put("2013-07-27T18:00:59.99999+01:00".length(),
              DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSZ"));
  parsers.put("2013-07-27T18:00:59.999999+01:00".length(),
              DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ"));
  parsers.put("2013-07-27T18:00:59.9999999+01:00".length(),
              DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSZ"));
}

public static Date parseDate(String date) {
  return parsers.get(date.length()).parseDateTime(date).toDate();
}

```

Is there a tidier way of doing this?