List of usage examples for java.util Locale US
Locale US
To view the source code for java.util Locale US.
Click Source Link
From source file:com.microsoft.windowsazure.core.tracing.util.JavaTracingInterceptorTest.java
@BeforeClass public static void setUSLocale() { locale = Locale.getDefault(); Locale.setDefault(Locale.US); }
From source file:Main.java
/** * Convert a string number into a double value * * @param text the text to be converted to number * @return the double value//ww w .j a v a 2 s . c om */ private static double stringToDouble(String text) { text = text.replaceAll(",", "."); NumberFormat nf = NumberFormat.getInstance(Locale.US); try { return nf.parse(text).doubleValue(); } catch (ParseException e) { Log.e(TAG, e.getMessage(), e); return 0.0; } }
From source file:Main.java
private static final Calendar getUtcDate(int year, int month, int dayOfMonth) { final Calendar calendar = Calendar.getInstance(UTC_TIMEZONE, Locale.US); calendar.clear();//from w w w. j ava2 s . co m calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); return calendar; }
From source file:Main.java
/** * Returns a hex string representation of the data provided. * * @param data The byte array containing the data to be turned into a hex string. * @param beginIndex The begin index, inclusive. * @param endIndex The end index, exclusive. * @return A string containing the hex representation of the data provided. *///ww w . j av a 2s . c om public static String getHexStringFromBytes(byte[] data, int beginIndex, int endIndex) { StringBuilder dataStringBuilder = new StringBuilder(endIndex - beginIndex); for (int i = beginIndex; i < endIndex; i++) { dataStringBuilder.append(String.format(Locale.US, "%02X", data[i])); } return dataStringBuilder.toString(); }
From source file:Main.java
@SuppressLint("NewApi") public static CompressFormat guessImageFormatC(String urlOrPath) { CompressFormat format = null;/*from w ww . jav a2 s.c om*/ String fileName; if (URLUtil.isNetworkUrl(urlOrPath)) { fileName = URLUtil.guessFileName(urlOrPath, null, null); } else if (urlOrPath.lastIndexOf('.') <= 0) { return null; } else { fileName = urlOrPath; } fileName = fileName.toLowerCase(Locale.US); if (fileName.endsWith(".png")) { format = CompressFormat.PNG; } else if (fileName.endsWith(".jpg") || fileName.endsWith(".jpeg")) { format = CompressFormat.JPEG; } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && fileName.endsWith(".webp")) { format = CompressFormat.WEBP; } return format; }
From source file:Main.java
public static String byteArrayToHexString(final byte[] b) { if (b == null || b.length == 0) return null; final StringBuffer sb = new StringBuffer(b.length * 3 - 1); for (final byte element : b) { if (sb.length() > 0) sb.append(':'); final int v = element & 0xff; if (v < 16) sb.append('0'); sb.append(Integer.toHexString(v)); }/*from www. j a v a2 s . c o m*/ return sb.toString().toUpperCase(Locale.US); }
From source file:Main.java
public static double[] decimalDegreesToDegreeMinutes(double fDegrees) { final double fAbsDegrees = Math.abs(fDegrees); int dAbsDegrees = (int) fAbsDegrees; // Adjust degrees if minutes calulate to 60, due to rounding errors: double fAbsMinutes = 60.0 * (fAbsDegrees - dAbsDegrees); String minutesString = String.format(Locale.US, "%1$06.3f", fAbsMinutes); if (minutesString.equals("60.000")) { dAbsDegrees = dAbsDegrees + 1;//from w w w . jav a 2 s . c o m fAbsMinutes = 0; } return new double[] { dAbsDegrees, fAbsMinutes }; }
From source file:Main.java
/** * Returns the scheme prefix like "http" from the URL spec, or null if the * spec doesn't start with a scheme. Scheme prefixes match this pattern: * {@code alpha ( alpha | digit | '+' | '-' | '.' )* ':'} *//*from www . ja va2 s.com*/ public static String getSchemePrefix(String spec) { int colon = spec.indexOf(':'); if (colon < 1) { return null; } for (int i = 0; i < colon; i++) { char c = spec.charAt(i); if (!isValidSchemeChar(i, c)) { return null; } } return spec.substring(0, colon).toLowerCase(Locale.US); }
From source file:Main.java
/** * Convert time to a string//from ww w. j a v a2 s.c om * * @param millis e.g.time/length from file * @return Formatted string (hh:)mm:ss */ public static String millisToString(long millis) { boolean negative = millis < 0; millis = Math.abs(millis); millis /= 1000; int sec = (int) (millis % 60); millis /= 60; int min = (int) (millis % 60); millis /= 60; int hours = (int) millis; String time; DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(Locale.US); format.applyPattern("00"); if (millis > 0) { time = (negative ? "-" : "") + hours + ":" + format.format(min) + ":" + format.format(sec); } else { time = (negative ? "-" : "") + min + ":" + format.format(sec); } return time; }
From source file:Main.java
/** * Parsing the TimeZone of time from milliseconds. * * @param milliseconds the number of milliseconds from 1970.1.1. * @return GRM Time, Format such as: {@value #FORMAT_HTTP_DATA}. *///from w w w . j a va2 s .c om public static String formatMillisToGMT(long milliseconds) { Date date = new Date(milliseconds); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(FORMAT_HTTP_DATA, Locale.US); simpleDateFormat.setTimeZone(GMT_TIME_ZONE); return simpleDateFormat.format(date); }