List of usage examples for java.lang String compareTo
public int compareTo(String anotherString)
From source file:Main.java
public static boolean isPastDate(String year, String month, String day) { try {//from w ww .j a v a2s .co m GregorianCalendar cal = new GregorianCalendar(); cal.setLenient(false); SimpleDateFormat fmDate = new SimpleDateFormat("yyyyMMdd"); String today = fmDate.format(cal.getTime()); cal.clear(); cal.set(Integer.parseInt(year), Integer.parseInt(month) - 1, Integer.parseInt(day)); String inputday = fmDate.format(cal.getTime()); if (inputday.compareTo(today) < 0) { return true; } else { return false; } } catch (IllegalArgumentException e) { return false; } }
From source file:Main.java
@Deprecated public static boolean isUpdate(Context context, String newVersionName) { PackageManager manager = context.getPackageManager(); try {/*from w w w. j a va 2 s. c om*/ PackageInfo packageInfo = manager.getPackageInfo(context.getPackageName(), 0); String oldVersionName = packageInfo.versionName; if (oldVersionName.compareTo(newVersionName) < 0) return true; } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:Main.java
private static List<String> getSortedGPXFilenames(File dir, String sub) { final List<String> list = new ArrayList<String>(); readGpxDirectory(dir, list, ""); Collections.sort(list, new Comparator<String>() { @Override// w ww . ja va 2 s . c o m public int compare(String object1, String object2) { if (object1.compareTo(object2) > 0) { return -1; } else if (object1.equals(object2)) { return 0; } return 1; } }); return list; }
From source file:Main.java
public static Bitmap getBitmapFromWeb(String imageURL) { Bitmap bitmap = null;/*from ww w . j ava 2s. c o m*/ if (imageURL != null && imageURL.compareTo("null") != 0) { try { InputStream in = new URL(DOMAIN + imageURL).openStream(); bitmap = BitmapFactory.decodeStream(in); } catch (Exception e) { e.printStackTrace(); } } return bitmap; }
From source file:Main.java
public static boolean isNegativeZero(String value) { if (is64BinaryString(value)) { if (value.compareTo(MINUSZERO) == 0) { return true; }/*from w ww .ja v a 2s . co m*/ } return false; }
From source file:Main.java
public static boolean isPositiveInfinity(String value) { if (is64BinaryString(value)) { if (value.compareTo(PLUSINFINITY) == 0) { return true; }//from ww w .j a v a 2s .com } return false; }
From source file:Main.java
/** * Get the list of xml files in the bookmark export folder. * @return The list of xml files in the bookmark export folder. *//*from w ww . j a v a 2 s.c om*/ public static List<String> getExportedBookmarksFileList() { List<String> result = new ArrayList<String>(); File folder = Environment.getExternalStorageDirectory(); if (folder != null) { FileFilter filter = new FileFilter() { @Override public boolean accept(File pathname) { if ((pathname.isFile()) && (pathname.getPath().toLowerCase(Locale.US).endsWith(".xml") || pathname.getPath().toLowerCase(Locale.US).endsWith(".json"))) { return true; } return false; } }; File[] files = folder.listFiles(filter); for (File file : files) { result.add(file.getName()); } } Collections.sort(result, new Comparator<String>() { @Override public int compare(String arg0, String arg1) { return arg1.compareTo(arg0); } }); return result; }
From source file:de.hadesrofl.json.JsonReader.java
/** * Reads a json file and returns it as JSONObject * * @param file/*from w ww .j a va 2 s . com*/ * is the file to read * @return an json object */ public static JSONObject readFile(String file) { if (file != null && file.compareTo("") != 0) return readFile(new File(file)); else return null; }
From source file:Main.java
private static void sortFieldsByName(Field[] array) { Arrays.sort(array, new Comparator<Field>() { @Override/* www . ja v a2 s .c o m*/ public int compare(Field current, Field next) { String currentName = current.getName(); String nextName = next.getName(); return currentName.compareTo(nextName); } }); }
From source file:com.nabla.wapp.server.database.CommonConnectionPool.java
public static boolean isLoaded(final String name) { final String[] names = driver.getPoolNames(); if (names == null) return false; for (final String n : names) { if (n.compareTo(name) == 0) return true; }/* w ww. j a va 2s .c o m*/ return false; }