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 SimpleDateFormat getApiSimpleDateFormat() {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(API_DATE_FORMAT, Locale.getDefault());
    simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    return simpleDateFormat;
}

From source file:Main.java

private static void init() {
    knownPatterns.add(new SimpleDateFormat("EEEE MMM dd hh:mm:ss z yyyy", Locale.getDefault()));
}

From source file:Main.java

public static Date parseDate_C(String dateStr) throws ParseException {
    return new SimpleDateFormat(formatC, Locale.getDefault()).parse(dateStr);
}

From source file:Main.java

public static Date parseDate_B(String dateStr) throws ParseException {
    return new SimpleDateFormat(formatB, Locale.getDefault()).parse(dateStr);
}

From source file:Main.java

public static Bundle bundleCalendar(Calendar cal) {
    Bundle args = new Bundle();
    if (cal == null)
        cal = Calendar.getInstance(Locale.getDefault());
    ;//from   w w  w  . j  av a2  s  . co  m
    args.putInt("year", cal.get(Calendar.YEAR));
    args.putInt("month", cal.get(Calendar.MONTH));
    args.putInt("day", cal.get(Calendar.DAY_OF_MONTH));
    args.putInt("hour", cal.get(Calendar.HOUR_OF_DAY));
    args.putInt("minute", cal.get(Calendar.MINUTE));
    return args;
}

From source file:Main.java

public static long parseTimeToLong(String time) {
    if (null == time)
        return System.currentTimeMillis();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault());
    sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
    java.util.Date d;/* ww  w. j ava 2  s.  c  om*/
    try {
        d = sdf.parse(time);
        return d.getTime();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return System.currentTimeMillis();
}

From source file:Main.java

/**
 * Checks current locale settings to select a language which should be used for communication with MCI.
 * /*from w w  w. ja  v a2 s .c  o  m*/
 * @return Code of language to use for MCI communication
 */
public static final String getMciLanguageCode() {
    String lowerLanguage = Locale.getDefault().getLanguage().toLowerCase(Locale.US);
    if (lowerLanguage.startsWith("cs") || lowerLanguage.startsWith("sk")) {
        return "cs";
    } else {
        return "en";
    }
}

From source file:Main.java

public static String formatDate(String date, String format) {
    // "ddd MM, yyyy"

    DateFormat sdf = new SimpleDateFormat(format, Locale.getDefault());
    Date parsedDate = new Date();

    try {/*www. ja  v a 2 s.co  m*/
        parsedDate = sdf.parse(date);
        parsedDate.toString();
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return "";
}

From source file:Main.java

/**
 * Get datetime/*from   w ww . java2  s . co  m*/
 * 
 * @return
 */
public static String getDateTime() {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
    Date date = new Date();
    return dateFormat.format(date);
}

From source file:Main.java

public static Date convertStringToDate(String date) {
    //TODO Set this date in a constant file
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
    try {//from w w  w. ja  v  a  2  s  . c om
        return format.parse(date);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}