Example usage for java.util Locale getDefault

List of usage examples for java.util Locale getDefault

Introduction

In this page you can find the example usage for java.util Locale getDefault.

Prototype

public static Locale getDefault() 

Source Link

Document

Gets the current value of the default locale for this instance of the Java Virtual Machine.

Usage

From source file:Main.java

private static String _bytes2Hex(byte[] b) {
    StringBuilder builder = new StringBuilder();
    String stmp = "";

    for (int i = 0; i < b.length; i++) {
        stmp = Integer.toHexString(b[i] & 0xFF);
        if (stmp.length() == 1) {
            builder.append("0" + stmp);
        } else {//from w  w w .  j  a v  a2s. c o m
            builder.append(stmp);
        }
    }

    return builder.toString().toUpperCase(Locale.getDefault());
}

From source file:Main.java

private static Boolean currentGreaterThenOld(String currentDate, String oldDate) {
    if (currentDate.isEmpty() || oldDate.isEmpty())
        return false;

    try {//w  ww.  java2s  .  co m
        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
        Date current = formatter.parse(currentDate);
        Date old = formatter.parse(oldDate);

        if (old.compareTo(current) < 0) {
            Log.d(TAG, "compareDate current Date : " + current.toString() + " is greater then Old Date : "
                    + old.toString());
            return true;
        }

    } catch (ParseException e1) {
        e1.printStackTrace();
    }
    return false;
}

From source file:Main.java

/**
 * Create an default file for save image from camera.
 *
 * @return/*w ww. j  a v a  2s  .c  o  m*/
 * @throws IOException
 */
public static File createDefaultImageFile() throws IOException {
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date());
    String imageFileName = "JPEG_" + timeStamp + ".jpg";
    File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
    if (!storageDir.exists()) {
        storageDir.mkdirs();
    }
    return new File(storageDir, imageFileName);
}

From source file:Main.java

public static int getDatePart(long time, int part) {
    if (time <= 0)
        return 0;
    Calendar cal = Calendar.getInstance(Locale.getDefault());
    cal.setTimeInMillis(time);/* w  w w . j  a va2  s .com*/
    return cal.get(part);
}

From source file:Main.java

private static Method getBooleanColumnSetMethod(Class<?> entityType, Field field, Class<?> typeClass,
        String suffix) {/*from w  ww  . j a v  a 2 s .co  m*/
    String fieldName = field.getName();
    String methodName = null;
    if (isStartWithIs(field.getName())) {
        methodName = "set" + fieldName.substring(2, 3).toUpperCase(Locale.getDefault()) + fieldName.substring(3)
                + suffix;
    } else {
        methodName = "set" + fieldName.substring(0, 1).toUpperCase(Locale.getDefault()) + fieldName.substring(1)
                + suffix;
    }
    try {
        return entityType.getDeclaredMethod(methodName, typeClass);
    } catch (NoSuchMethodException e) {
        Log.d("L", methodName + " not exist");
    }
    return null;
}

From source file:Main.java

/**
 * Parse the date from server to String for local database
 *
 * @param date_received date received from server
 * @return Date for storing in local database
 */// w w  w  .j a va 2 s. c  om
public static Date parseDateFromString(String date_received) {
    //2014-06-28 14:56:59
    SimpleDateFormat dateFormat_received = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss", Locale.getDefault());
    Date date = null;
    try {
        date = dateFormat_received.parse(date_received);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date;
}

From source file:Main.java

public static void changeAppLanguage(Resources resources, String lanAtr) {
    Configuration config = resources.getConfiguration();
    DisplayMetrics dm = resources.getDisplayMetrics();
    if (lanAtr.equals("zh-cn")) {
        config.locale = Locale.SIMPLIFIED_CHINESE;
    } else {//from   ww  w  .  j  a  va  2  s .  c o m
        config.locale = Locale.getDefault();
    }
    resources.updateConfiguration(config, dm);
}

From source file:Main.java

public static String getPPLink() {
    return constructLink(Locale.getDefault(), "/privacy");
}

From source file:Main.java

public static String getTOSLink() {
    return constructLink(Locale.getDefault(), "/tospage");
}

From source file:Main.java

public static String getWeek(Date date) {
    return new SimpleDateFormat("EEEE", Locale.getDefault()).format(date);
}