Example usage for java.util Locale US

List of usage examples for java.util Locale US

Introduction

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

Prototype

Locale US

To view the source code for java.util Locale US.

Click Source Link

Document

Useful constant for country.

Usage

From source file:Main.java

public static String getShortMonthYearDisplay(Calendar cal) {
    return cal.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.US) + " " + cal.get(Calendar.YEAR);
}

From source file:Main.java

public static SimpleDateFormat getDateFormat() {
    final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US);
    format.setTimeZone(TimeZone.getTimeZone("UTC"));
    return format;
}

From source file:Main.java

public static String getStrFromTime(long time) {
    return new SimpleDateFormat("yyyy-MM-dd kk:mm:ss", Locale.US).format(new Date(time));
}

From source file:Main.java

public static long getLongFromDate(String date) {

    SimpleDateFormat sdf = new SimpleDateFormat("E,dd MMM yyyy", Locale.US);
    long time = 0;
    try {//  w w  w .ja  v  a 2 s  . c  o m
        time = sdf.parse(date).getTime();
    } catch (ParseException e) {

        e.printStackTrace();

    }
    return time;
}

From source file:Main.java

public static String getTOSLink() {
    String link = "http://m.google.com/toscountry"; // default

    String locale = Locale.getDefault().toString();
    if (locale.equals(Locale.US.toString())) {
        link = "http://m.google.com/tospage";
    } else if (locale.equals(Locale.UK.toString())) {
        link = "http://m.google.co.uk/tospage";
    } else if (locale.equals(Locale.CANADA.toString())) {
        link = "http://m.google.ca/tospage";
    } else if (locale.equals(Locale.CANADA_FRENCH.toString())) {
        link = "http://m.google.ca/tospage?hl=fr";
    } else if (locale.equals(Locale.FRANCE.toString())) {
        link = "http://m.google.fr/tospage";
    }//  ww w.  jav a 2s.c o m
    return link;
}

From source file:Main.java

public static String dateToString(Date date, String format) {
    DateFormat df = new SimpleDateFormat(format, Locale.US);
    return df.format(date);
}

From source file:Main.java

public static String getTimestamp() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US);
    sdf.setTimeZone(TimeZone.getDefault());
    String tmp = sdf.format(new Date());
    tmp = tmp.substring(0, 22) + ":" + tmp.substring(22);
    return tmp;/*from  w w w. ja  va  2 s.  c o m*/
}

From source file:Main.java

public static long getLongForPresentDate(String date) {

    SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy", Locale.US);
    long time = 0;
    try {//  w  w  w  .  jav  a  2s  .  com
        time = sdf.parse(date).getTime();
    } catch (ParseException e) {

        e.printStackTrace();

    }
    return time;
}

From source file:Main.java

public static String padWithZerosToMaxIntWidth(int paramInt) {
    if (paramInt < 0) {
        throw new IllegalArgumentException("value must be zero or greater");
    }/*from w  ww.  ja va  2s.  c om*/
    return String.format(Locale.US, "%1$10s", new Object[] { Integer.valueOf(paramInt) }).replace(' ', '0');
}

From source file:Main.java

public static String getDayOfWeek(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat("E", Locale.US);
    if (date != null) {
        return sdf.format(date);
    } else {//from   ww w  . j a v  a 2  s.co  m
        return "???";
    }

}