MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / toDateValue

Method toDateValue

CodenameOne/src/com/codename1/io/Util.java:2605–2628  ·  view source on GitHub ↗
(Object o)

Source from the content-addressed store, hash-verified

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.

Callers 3

setSimpleObjectMethod · 0.95
compareMethod · 0.95
invokeStatic16Method · 0.80

Calls 3

eMethod · 0.95
toLongValueMethod · 0.95
parseMethod · 0.45

Tested by

no test coverage detected