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

public static String getFormattedDate(long milliseconds) {
    return new SimpleDateFormat("EEEE MMMM d, yyyy", Locale.getDefault()).format(new Date(milliseconds));
}

From source file:Main.java

public static String convertToDateSimple(Date date) {
    DateFormat format = new SimpleDateFormat("EEE, MMM. d '\n'h:mm a", Locale.getDefault());
    return format.format(date);
}

From source file:Main.java

private static Locale getLocale() {
    if (sLocale == null) {
        sLocale = Locale.getDefault();
    }
    return sLocale;
}

From source file:Main.java

public static String getTime(long milliseconds) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm", Locale.getDefault());
    return dateFormat.format(new Date(milliseconds));
}

From source file:Main.java

public static String getDate(long milliseconds) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM dd", Locale.getDefault());
    return dateFormat.format(new Date(milliseconds));
}

From source file:Main.java

public static String stringForTime(int timeMs) {

    StringBuilder mFormatBuilder = new StringBuilder();
    Formatter mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());

    int totalSeconds = timeMs / 1000;

    int seconds = totalSeconds % 60;
    int minutes = (totalSeconds / 60) % 60;
    int hours = totalSeconds / 3600;

    mFormatBuilder.setLength(0);// ww w  .ja v a 2  s  . c  o m
    if (hours > 0) {
        return mFormatter.format("%d:%02d:%02d", hours, minutes, seconds).toString();
    } else {
        return mFormatter.format("%02d:%02d", minutes, seconds).toString();
    }
}

From source file:Main.java

/**
 * Format minutes for display./* w w w.  ja va 2  s.  c o  m*/
 * @param minutes to be formatted
 * @return String representation of minutes as "hh:mm"
 */
public static String formatMinutes(int minutes) {
    return String.format(Locale.getDefault(), "%d:%02d", minutes / 60, (minutes % 60));
}

From source file:Main.java

/**
 * Returns the language code for this Locale or the empty string if no language was set.
 *//*  ww w .  j a  v  a  2  s  . c om*/
public static String getLanguage() {
    String language = null;
    try {
        language = Locale.getDefault().getLanguage();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return language;
}

From source file:Main.java

public static String getDate() {
    Date date = new Date();
    DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());

    return format.format(date);
}

From source file:Main.java

public static String convertCurrentTimeToGmt(String format) {
    final SimpleDateFormat dateFormatGmt = new SimpleDateFormat(format, Locale.getDefault());
    dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
    return dateFormatGmt.format(new Date());
}