From e52d4fc0035546c6bbd93a60f02bd887fddab7cc Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Fri, 7 Jun 2013 16:43:53 -0700 Subject: [PATCH] CB-3736: Cleaning up code so that this makes more sense. Variables are OK --- framework/src/org/apache/cordova/Globalization.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/framework/src/org/apache/cordova/Globalization.java b/framework/src/org/apache/cordova/Globalization.java index 5c75e100..4fac0746 100644 --- a/framework/src/org/apache/cordova/Globalization.java +++ b/framework/src/org/apache/cordova/Globalization.java @@ -260,12 +260,13 @@ public class Globalization extends CordovaPlugin { String fmt = fmtDate.toLocalizedPattern() + " " + fmtTime.toLocalizedPattern(); //default SHORT date/time format. ex. dd/MM/yyyy h:mm a //get Date value + options (if available) - if (options.getJSONObject(0).length() > 1){ + boolean test = options.getJSONObject(0).has(OPTIONS); + if (options.getJSONObject(0).has(OPTIONS)){ //options were included - + JSONObject innerOptions = options.getJSONObject(0).getJSONObject(OPTIONS); //get formatLength option - if (!((JSONObject)options.getJSONObject(0).get(OPTIONS)).isNull(FORMATLENGTH)){ - String fmtOpt = (String)((JSONObject)options.getJSONObject(0).get(OPTIONS)).get(FORMATLENGTH); + if (!innerOptions.isNull(FORMATLENGTH)){ + String fmtOpt = innerOptions.getString(FORMATLENGTH); if (fmtOpt.equalsIgnoreCase(MEDIUM)){//medium fmtDate = (SimpleDateFormat)android.text.format.DateFormat.getMediumDateFormat(this.cordova.getActivity()); }else if (fmtOpt.equalsIgnoreCase(LONG) || fmtOpt.equalsIgnoreCase(FULL)){ //long/full @@ -275,8 +276,8 @@ public class Globalization extends CordovaPlugin { //return pattern type fmt = fmtDate.toLocalizedPattern() + " " + fmtTime.toLocalizedPattern(); - if (!((JSONObject)options.getJSONObject(0).get(OPTIONS)).isNull(SELECTOR)){ - String selOpt = (String)((JSONObject)options.getJSONObject(0).get(OPTIONS)).get(SELECTOR); + if (!innerOptions.isNull(SELECTOR)){ + String selOpt = innerOptions.getString(SELECTOR); if (selOpt.equalsIgnoreCase(DATE)){ fmt = fmtDate.toLocalizedPattern(); }else if (selOpt.equalsIgnoreCase(TIME)){