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:Main.java
public static Object getProperty(Object o, String field) { try {//from www . j a v a 2s . c o m Field f = o.getClass().getDeclaredField(field); f.setAccessible(true); String name = f.getName(); name = name.replaceFirst(name.substring(0, 1), name.substring(0, 1).toUpperCase(Locale.US)); Method m = o.getClass().getMethod("get" + name); // return f.get(o); return (Object) m.invoke(o); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:Main.java
private static String format(String format, Object... args) { return String.format(Locale.US, format, args); }
From source file:Main.java
private static String formatPeriodDate(int daysPeriod) { Calendar now = Calendar.getInstance(); Calendar period = Calendar.getInstance(); period.add(Calendar.DAY_OF_MONTH, daysPeriod); SimpleDateFormat sdf = new SimpleDateFormat("MMMM", Locale.US); if (now.get(Calendar.YEAR) == period.get(Calendar.YEAR)) { if (now.get(Calendar.MONTH) == period.get(Calendar.MONTH)) { return period.get(Calendar.DAY_OF_MONTH) + "-" + now.get(Calendar.DAY_OF_MONTH) + " " + sdf.format(now.getTime()) + ", " + now.get(Calendar.YEAR); }// www.j a va 2 s . c om return period.get(Calendar.DAY_OF_MONTH) + " " + sdf.format(period.getTime()) + " - " + now.get(Calendar.DAY_OF_MONTH) + " " + sdf.format(now.getTime()) + ", " + now.get(Calendar.YEAR); } return period.get(Calendar.DAY_OF_MONTH) + " " + sdf.format(period.getTime()) + " " + period.get(Calendar.YEAR) + " - " + now.get(Calendar.DAY_OF_MONTH) + " " + sdf.format(now.getTime()) + " " + now.get(Calendar.YEAR); }
From source file:Main.java
public static String byteArrayToHexString(byte[] b) { StringBuffer sb = new StringBuffer(b.length * 2); for (int i = 0; i < b.length; i++) { int v = b[i] & 0xff; if (v < 16) { sb.append('0'); }// ww w . j a v a 2 s .com sb.append(Integer.toHexString(v)); } return sb.toString().toUpperCase(Locale.US); }
From source file:Main.java
@Deprecated public static NdefRecord createExternal(String domain, String type, byte[] data) { if (domain == null) throw new NullPointerException("domain is null"); if (type == null) throw new NullPointerException("type is null"); domain = domain.trim().toLowerCase(Locale.US); type = type.trim().toLowerCase(Locale.US); if (domain.length() == 0) throw new IllegalArgumentException("domain is empty"); if (type.length() == 0) throw new IllegalArgumentException("type is empty"); byte[] byteDomain = domain.getBytes(Charset.forName("UTF_8")); byte[] byteType = type.getBytes(Charset.forName("UTF_8")); byte[] b = new byte[byteDomain.length + 1 + byteType.length]; System.arraycopy(byteDomain, 0, b, 0, byteDomain.length); b[byteDomain.length] = ':'; System.arraycopy(byteType, 0, b, byteDomain.length + 1, byteType.length); return new NdefRecord(NdefRecord.TNF_EXTERNAL_TYPE, b, new byte[0], data); }
From source file:Main.java
public static boolean isASFFile(String in) { in = in.toLowerCase(Locale.US); return in.endsWith(".asf") || in.endsWith(".wm"); }
From source file:Main.java
/** * Convert byte array to hex string// w w w .j a va 2 s.co m * * @param bytes * @return */ public static String bytesToHex(byte[] bytes) { StringBuilder sbuf = new StringBuilder(); for (int idx = 0; idx < bytes.length; idx++) { int intVal = bytes[idx] & 0xff; if (intVal < 0x10) sbuf.append("0"); sbuf.append(Integer.toHexString(intVal).toUpperCase(Locale.US)); } return sbuf.toString(); }
From source file:Main.java
public static java.util.Date ConvertFromWebService(String strDate) { java.lang.String[] formats = new java.lang.String[] { "yyyy-MM-dd'T'HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", "yyyy-MM-dd'T'HH:mm:ss", "yyyy-MM-dd'T'HH:mm", "yyyy-MM-dd" }; for (java.lang.String frm : formats) { try {//from w ww . j a v a 2s.c o m SimpleDateFormat format = new SimpleDateFormat(frm, Locale.US); format.setTimeZone(java.util.TimeZone.getTimeZone("UTC")); return format.parse(strDate); } catch (java.lang.Exception ex) { } } return null; }
From source file:Main.java
public static boolean isMP3File(String in) { boolean retVal = false; in = in.toLowerCase(Locale.US); if (in.endsWith(".mp3")) retVal = true;//from w w w .j a v a 2s . c om return retVal; }
From source file:Main.java
@Nullable public static Date parseDate(@NonNull String format, @Nullable String date) { if (date == null) { return null; }//from w ww. j a v a 2 s . co m final SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.US); formatter.setLenient(false); try { return formatter.parse(date); } catch (ParseException e) { return null; } }