mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 15:12:51 +08:00
CB-3736: Cleaning up code so that this makes more sense. Variables are OK
This commit is contained in:
parent
3753e3f353
commit
e52d4fc003
@ -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)){
|
||||
|
Loading…
Reference in New Issue
Block a user