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:io.github.medinam.jcheesum.util.VersionChecker.java

public static void showDownloadLatestAlert() {
    Alert alert = new Alert(Alert.AlertType.INFORMATION);

    ResourceBundle resources = ResourceBundle.getBundle("i18n/Bundle", Locale.getDefault());

    alert.setTitle(resources.getString("newVersion"));
    alert.setHeaderText(resources.getString("newVersionLooksLike"));
    alert.setContentText(resources.getString("youHave") + App.class.getPackage().getImplementationVersion()
            + " " + resources.getString("latestVersionIs") + getLatestStable() + "\n\n"
            + resources.getString("wannaDownload"));

    ButtonType yesBtn = new ButtonType(resources.getString("yes"));
    ButtonType noBtn = new ButtonType(resources.getString("no"), ButtonBar.ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(yesBtn, noBtn);

    Optional<ButtonType> o = alert.showAndWait();

    if (o.get() == yesBtn) {
        General.openLink(getLatestStableDownloadURL());
    } else if (o.get() == noBtn) {
        alert.close();//from   ww  w  . j a v  a  2 s .  co  m
    }
}

From source file:cool.pandora.modeller.ui.util.ApplicationContextUtil.java

/**
 * getMessage./*from   ww  w  . j a v  a2 s. c o m*/
 *
 * @param propertyName String
 * @return message
 */
public static String getMessage(final String propertyName) {
    return Application.instance().getApplicationContext().getMessage(propertyName, null, propertyName,
            Locale.getDefault());
}

From source file:Main.java

/**
 * Converts byte data to a Hex-encoded string.
 *
 * @param data//from w w w  . j av  a2s. c om
 *            data to hex encode.
 *
 * @return hex-encoded string.
 */
public static String toHex(byte[] data) {
    StringBuilder sb = new StringBuilder(data.length * 2);
    for (int i = 0; i < data.length; i++) {
        String hex = Integer.toHexString(data[i]);
        if (hex.length() == 1) {
            // Append leading zero.
            sb.append("0");
        } else if (hex.length() == 8) {
            // Remove ff prefix from negative numbers.
            hex = hex.substring(6);
        }
        sb.append(hex);
    }
    return sb.toString().toLowerCase(Locale.getDefault());
}

From source file:Main.java

public TextBoundaryFrame() {
    getContentPane().add(new JScrollPane(outputText));

    Locale currentLocale = Locale.getDefault();
    BreakIterator currentBreakIterator = BreakIterator.getSentenceInstance(currentLocale);

    String text = "The quick, brown fox jump-ed\n" + "over the lazy \"dog.\" And then...what happened?";
    currentBreakIterator.setText(text);//from  w  ww. ja va2  s  . c o m
    outputText.setText("");

    int from = currentBreakIterator.first();
    int to;
    while ((to = currentBreakIterator.next()) != BreakIterator.DONE) {
        outputText.append(text.substring(from, to) + "|");
        from = to;
    }
    outputText.append(text.substring(from));
}

From source file:Main.java

public TextBoundaryFrame() {
    getContentPane().add(new JScrollPane(outputText));

    Locale currentLocale = Locale.getDefault();
    BreakIterator currentBreakIterator = BreakIterator.getLineInstance(currentLocale);

    String text = "The quick, brown fox jump-ed\n" + "over the lazy \"dog.\" And then...what happened?";
    currentBreakIterator.setText(text);/*from w w w .j av  a2  s. c  o  m*/
    outputText.setText("");

    int from = currentBreakIterator.first();
    int to;
    while ((to = currentBreakIterator.next()) != BreakIterator.DONE) {
        outputText.append(text.substring(from, to) + "|");
        from = to;
    }
    outputText.append(text.substring(from));
}

From source file:Main.java

public TextBoundaryFrame() {
    getContentPane().add(new JScrollPane(outputText));

    Locale currentLocale = Locale.getDefault();
    BreakIterator currentBreakIterator = BreakIterator.getWordInstance(currentLocale);

    String text = "The quick, brown fox jump-ed\n" + "over the lazy \"dog.\" And then...what happened?";
    currentBreakIterator.setText(text);//w  ww  .  j a v a2  s.  c o  m
    outputText.setText("");

    int from = currentBreakIterator.first();
    int to;
    while ((to = currentBreakIterator.next()) != BreakIterator.DONE) {
        outputText.append(text.substring(from, to) + "|");
        from = to;
    }
    outputText.append(text.substring(from));
}

From source file:dk.laundav.locationservice.service.LocationService.java

public static LocationObject getLocationFromGeocoder(Context context) {

    gps = new GPSTracker(context);

    // check if GPS enabled     
    if (gps.canGetLocation()) {

        double latitude = gps.getLatitude();
        double longitude = gps.getLongitude();

        Geocoder geocoder = new Geocoder(context, Locale.getDefault());

        LocationObject location = new LocationObject(latitude, longitude);

        try {//  w w  w .j av a  2  s.  c  om

            // addresses er altid lig 0 (ingen elementer)
            List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(),
                    1);

            if (addresses != null && addresses.size() > 0) {

                System.out.println("The geocoder works!");

                location.setLocation(addresses.get(0).getAddressLine(0), // address
                        addresses.get(0).getAddressLine(1), // city
                        addresses.get(0).getAddressLine(2) // country
                );

            }

            return location;

        } catch (IOException e) {
            e.printStackTrace();
            return location;
        }

    } else {
        // can't get location
        // GPS or Network is not enabled
        // Ask user to enable GPS/network in settings
        gps.showSettingsAlert();
        return null;
    }
}

From source file:Main.java

/**
 * @return the old style locale string constructed from
 *         {@link Settings.Secure#TTS_DEFAULT_LANG},
 *         {@link Settings.Secure#TTS_DEFAULT_COUNTRY} and
 *         {@link Settings.Secure#TTS_DEFAULT_VARIANT}. If no such locale is
 *         set, then return the default phone locale.
 *///from w w  w . j a va  2 s. c  o  m
@SuppressWarnings({ "deprecation", "javadoc" })
private static Locale getV1Locale(ContentResolver resolver) {
    final String language = Settings.Secure.getString(resolver, Settings.Secure.TTS_DEFAULT_LANG);
    if (TextUtils.isEmpty(language)) {
        return Locale.getDefault();
    }

    final String country = Settings.Secure.getString(resolver, Settings.Secure.TTS_DEFAULT_COUNTRY);
    final String variant = Settings.Secure.getString(resolver, Settings.Secure.TTS_DEFAULT_VARIANT);
    final String locale = constructLocaleString(language, country, variant);

    return new Locale(locale);
}

From source file:Main.java

public TextBoundaryFrame() {
    getContentPane().add(new JScrollPane(outputText));

    Locale currentLocale = Locale.getDefault();
    BreakIterator currentBreakIterator = null;
    currentBreakIterator = BreakIterator.getCharacterInstance(currentLocale);

    String text = "The quick, brown fox jump-ed\n" + "over the lazy \"dog.\" And then...what happened?";
    currentBreakIterator.setText(text);//from w  w w .j av a 2s  .c o m
    outputText.setText("");

    int from = currentBreakIterator.first();
    int to;
    while ((to = currentBreakIterator.next()) != BreakIterator.DONE) {
        outputText.append(text.substring(from, to) + "|");
        from = to;
    }
    outputText.append(text.substring(from));
}

From source file:com.cburch.logisim.util.LocaleManager.java

public static Locale getLocale() {
    if (curLocale == null) {
        curLocale = Locale.getDefault();
    }
    return curLocale;
}