(Object o)
| 2603 | /// |
| 2604 | /// a Date object |
| 2605 | public static Date toDateValue(Object o) { |
| 2606 | if (o == null) { |
| 2607 | return null; |
| 2608 | } |
| 2609 | if (o instanceof Date) { |
| 2610 | return (Date) o; |
| 2611 | } |
| 2612 | if (o instanceof String) { |
| 2613 | if (dateFormatter != null) { |
| 2614 | try { |
| 2615 | return dateFormatter.parse((String) o); |
| 2616 | } catch (ParseException e) { |
| 2617 | // falls back to the default formatting |
| 2618 | Log.e(e); |
| 2619 | } |
| 2620 | } |
| 2621 | try { |
| 2622 | return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse((String) o); |
| 2623 | } catch (ParseException e) { |
| 2624 | throw new IllegalArgumentException("Not a supported date, we use this format 'yyyy-MM-dd'T'HH:mm:ss.SSS': " + o, e); |
| 2625 | } |
| 2626 | } |
| 2627 | return new Date(toLongValue(o)); |
| 2628 | } |
| 2629 | |
| 2630 | /// Encodes a string in a way that makes it harder to read it "as is" this makes it possible for Strings to be |
| 2631 | /// "encoded" within the app and thus harder to discover by a casual search. |
no test coverage detected