Keywords: network status, system settings, system time, and time formatting first determine the network status of the system/*** determine the network connection status * @ return true, available; false, */private boolean isOpenNetwork () {ConnectivityManager connManager = (ConnectivityManager) getSystemService (Context. CONNECTIVITY_SERVICE); if (connManager. getActiveNetworkInfo ()! = Null) {return connManager. getActiveNetworkInfo (). isAvailable ();} return false;} PS: You must add the network access permission [html] <uses-permission android: name = "android. permission. INTERNET "> </uses-permission> <uses-permission android: name =" android. permission. ACCESS_NETWORK_STATE "/> if there is no network, enter the setting interface [java] if (isOpenNetwork () = true) {} else {AlertDialog. builder builder = new AlertDialog. builder (SomeActivity. this); buil Der. setTitle ("title "). setMessage ("message"); builder. setPositiveButton (resources. getString (R. string. OK), new DialogInterface. onClickListener () {@ Override public void onClick (DialogInterface dialog, int which) {<span style = "white-space: pre"> </span> Intent intent = null; try {String sdkVersion = android. OS. build. VERSION. SDK; if (Integer. valueOf (sdkVersion)> 10) {intent = new Intent (android. pr Ovider. settings. ACTION_SETTINGS);} else {intent = new Intent (); ComponentName comp = new ComponentName ("com. android. settings "," com. android. settings. settings "); intent. setComponent (comp); intent. setAction ("android. intent. action. VIEW ");} SomeActivity. this. startActivity (intent);} catch (Exception e) {Log. v ("LOG", "open network settings failed, please check... "); <span style =" white-space: pre "> </Span> e. printStackTrace (); <span style = "white-space: pre" ></ span> }}}). setNegativeButton (resources. getString (R. string. no), new DialogInterface. onClickListener () {@ Override public void onClick (DialogInterface dialog, int which) {dialog. cancel (); finish ();}}). show ();} Here we will extend it through android. provider. settings can get a lot of information we need related to system Settings, such as whether the system time is 24 or 12 [java] ContentResolver cv = this. getContentResolver (); S Tring strTimeFormat = android. provider. settings. system. getString (cv, android. provider. settings. system. TIME_12_24); if (strTimeFormat. equals ("24") {Log. I ("activity", "24 .. This blog is quite complicated, so you can format the time and get the system time. [java] SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM "); // The Time Format String date = sdf. format (new java. util. date (); Use Calendar to obtain [java] Calendar c = Calendar. getInstance (); system date: year = c. get (Calendar. YEAR) month = c. grt (Calendar. MONTH) day = c. get (Calendar. DAY_OF_MONTH) obtain the system time: hour = c. get (Calendar. HOUR_OF_DAY); minute = c. get (Calendar. MINUTE) Calendar c = Calen Dar. getInstance (); system date: year = c. get (Calendar. YEAR) month = c. grt (Calendar. MONTH) day = c. get (Calendar. DAY_OF_MONTH) obtain the system time: hour = c. get (Calendar. HOUR_OF_DAY); minute = c. get (Calendar. MINUTE) use Time to obtain [java] Time t = new Time (); // or Time t = new Time ("GMT + 8"); plus Time Zone information. T. setToNow (); // obtain the system time. Int year = t. year; int month = t. month; int date = t. monthDay; int hour = t. hour; // 0-23 int minute = t. minute; int second = t. second;