List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:Main.java
public static String convertDateToString(Date date) { //TODO Set this date in a constant file SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); try {/* w w w . j av a 2 s. c o m*/ return format.format(date); } catch (Exception e) { e.printStackTrace(); return ""; } }
From source file:Main.java
public static String getFormattedDateForReQuery(long timeStampInMilliSeconds) { DateFormat df = new SimpleDateFormat("yyyyy-MM-dd HH:mm:ssZ", Locale.getDefault()); Date d = new Date(timeStampInMilliSeconds); return df.format(d); }
From source file:Main.java
public final static Date stringToDate(String dateString) { ParsePosition position = new ParsePosition(0); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); Date dateValue = simpleDateFormat.parse(dateString, position); return dateValue; }
From source file:Main.java
public static String getLocalizedAssetPath(AssetManager assetManager, String pathTemplate) { String path = String.format(Locale.US, pathTemplate, "-" + Locale.getDefault().getLanguage().toLowerCase()); try {//w w w.ja va 2 s. com InputStream is = assetManager.open(path); is.close(); } catch (Exception ex) { path = String.format(Locale.US, pathTemplate, ""); } return "file:///android_asset/" + path; }
From source file:Main.java
private static int howOld(final Date birthday) { int r = -1;//from w w w.j av a 2 s. com Date now = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy", Locale.getDefault()); String birthdayY = sdf.format(birthday); String nowY = sdf.format(now); r = Integer.parseInt(nowY) - Integer.parseInt(birthdayY); if (r != -1) { if (isOver(birthday)) { r += 1; } } return r; }
From source file:Main.java
public static String sGetDecimalStringAnyLocaleAs1Pt5LocalisedString(String value) { Locale theLocale = Locale.getDefault(); NumberFormat numberFormat = DecimalFormat.getInstance(theLocale); Number theNumber;/* w w w . java 2 s .c o m*/ try { theNumber = numberFormat.parse(value); } catch (ParseException e) { //value = sConvertDigits(value); String valueWithDot = value.replaceAll(",", "."); theNumber = Double.valueOf(valueWithDot); } // String.format uses the JVM's default locale. //String s = String.format(Locale.US, "%.2f", price); NumberFormat outputFormat = DecimalFormat.getInstance(theLocale); outputFormat.setMinimumIntegerDigits(1); outputFormat.setMinimumFractionDigits(5); outputFormat.setMaximumFractionDigits(5); String theStringResult = outputFormat.format(theNumber); //String theStringResult = String.format("%1.5f", theDoubleValue.doubleValue()); return theStringResult; }
From source file:Main.java
public static String getCountry(Context context) { Configuration configuration = context.getResources().getConfiguration(); String country = configuration.locale.getCountry(); return country.toLowerCase(Locale.getDefault()); }
From source file:Main.java
public static String getStringFormatDate(Date date) { if (date == null) { return null; }//from w w w .j a v a2 s . co m SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); return dateFormat.format(date); }
From source file:Main.java
public static long getCurrMillis() { long _t = 0L; try {/*from w w w . j a v a 2 s. c o m*/ _t = Calendar.getInstance(Locale.getDefault()).getTimeInMillis(); return _t; } catch (IllegalArgumentException e) { e.printStackTrace(); } _t = new Date().getTime(); return _t; }
From source file:Main.java
public static String getDateTimeString(Calendar calendar) { int year = calendar.get(Calendar.YEAR); // if (year>3900) year-=1900; SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy", Locale.getDefault()); //Date date = new Date(); return dateFormat .format(new Date(year - 1900, calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH))); }