private boolean CheckLoadDataDate(String dataLoadDate) { DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); Date DLD; try { DLD = df.parse(dataLoadDate); } catch (java.text.ParseException e) { DLD = null; } Calendar cal = Calendar.getInstance(); // creates calendar cal.setTime(new Date()); // sets calendar time/date cal.add(Calendar.HOUR_OF_DAY, -24); // adds -16 hours Date currentTime24 = cal.getTime(); if (DLD != null) { if (currentTime24.after(DLD)) { AlertView.showAlert( "Current tablet data is more than 24 hours old. Please download new data.", this); return false; } } else { AlertView.showAlert("Current tablet data is more than 24 hours old", this); return false; } return true; }
private void VersionControl() { String[] HHVersionString = GlobalCache.Version.split("\\."); int handheldVersion = Integer.parseInt(HHVersionString[0] + HHVersionString[1] + HHVersionString[2]); int handheldD3Version = Integer.parseInt( VersionNumber.split("\\.")[0] + VersionNumber.split("\\.")[1] + VersionNumber.split("\\.")[2]); if (handheldVersion < handheldD3Version) { AlertView.showAlert( "Please contact system administrator to get latest version of app\nLatest Version: " + VersionNumber + "\nCurrent Version: " + GlobalCache.Version, MainUI.this); } GlobalCache.Prefs = getSharedPreferences("label", 0); GlobalCache.Editor = GlobalCache.Prefs.edit(); GlobalCache.Editor.putString("DataLoadDate", DataLoad).commit(); AppVersion.setText( "App Version: " + GlobalCache.Version + "\nLast Data Load Date: " + DataLoad); CheckLoadDataDate(DataLoad); }