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

/**
 * Helper method to get the date and time from timestamp. Converts the Timestamp in Milliseconds to Date and Time and then
 * formats the Date object with {@link Format} and returns the String of Date and Time separately respectively
 *
 * @return String[] containing Date and Time
 *///from   w w  w.  jav a 2s. c  om
public static String[] getDateAndTimeSeparate(long timestamp) {
    Date date = new Date(timestamp);
    Format dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss", Locale.US);
    String dateTime = dateFormat.format(date);
    return dateTime.split(" ");
}

From source file:Main.java

/**
 * Returns true if the string starts with http:// or https://.
 *
 * @param uri string to evaluate//from w ww  .  ja  va2  s  .c  o  m
 * @return true if the string starts with http:// or https://
 */
public static boolean startsWithHttpOrHttps(String uri) {
    if (uri == null) {
        return false;
    }

    // the scheme is case insensitive, according to RFC 7230, section 2.7.3:
    /*
    The scheme and host
    are case-insensitive and normally provided in lowercase; all other
    components are compared in a case-sensitive manner.
     */
    String lowercaseUri = uri.toLowerCase(Locale.US);

    return lowercaseUri.startsWith("http://") || lowercaseUri.startsWith("https://");
}

From source file:Main.java

public static String getFormattedDate(Date date) {

    String resp = "";
    try {/*  w w  w  .  j  a  v a  2s.  co  m*/
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US);
        resp = sdf.format(date);
    } catch (Exception ex) {
    }
    return resp;
}

From source file:com.surfs.storage.web.utils.Stringutils.java

public static String compareReturnBerfore(String baseDate, String strDate) {
    SimpleDateFormat sdf_us = new SimpleDateFormat("EEE MMM dd HH:mm yyyy", Locale.US);
    SimpleDateFormat sdf_cn = new SimpleDateFormat("yyyy-MM-dd HH:mm");

    if (StringUtils.isBlank(baseDate)) {
        if (StringUtils.isBlank(strDate)) {
            return null;
        } else {//www.jav a  2s. com
            try {
                Date date = sdf_us.parse(strDate);
                return sdf_cn.format(date);
            } catch (ParseException e) {
                e.printStackTrace();
                return null;
            }
        }
    }

    try {
        /*String date_us1 = sdf_cn.format(sdf_us.parse(strDate1));*/
        String date_us2 = sdf_cn.format(sdf_us.parse(strDate));
        if (baseDate.compareTo(date_us2) <= 0)
            return baseDate;
        else if (baseDate.compareTo(date_us2) > 0)
            return date_us2;
    } catch (ParseException e) {
        e.printStackTrace();
        return null;
    }
    return strDate;
}

From source file:Main.java

private static String setNMEAformat(double latlong) {
    /*//from  w  ww . ja v a 2s  . com
      double latlongInt = Math.floor(latlong);
      double latLonDecimal = 60.0D * (latlong - latlongInt);
            
      String latLonDecimalStr = String.format(Locale.US, "%7.5f", latLonDecimal);
      if (latLonDecimalStr.indexOf(".") < 2)
      latLonDecimalStr = "0" + latLonDecimalStr;
            
      return String.format(Locale.US, "%1.0f", latlongInt) + latLonDecimalStr;
     */
    int latlongInt = (int) latlong;
    double latLonDecimal = 60.0D * (latlong % 1);

    String latLonDecimalStr = String.format(Locale.US, "%7.5f", latLonDecimal);
    if (latLonDecimalStr.indexOf(".") < 2)
        latLonDecimalStr = "0" + latLonDecimalStr;

    return String.format(Locale.US, "%d", latlongInt) + latLonDecimalStr;
}

From source file:Main.java

public static String computeWeakHash(String string) {
    return String.format(Locale.US, "%08x%08x", string.hashCode(), string.length());
}

From source file:Main.java

public static boolean isWebSocketEndpoint(String url) {
    String urlLowerCase = url.toLowerCase(Locale.US);
    return urlLowerCase.startsWith("ws://") || urlLowerCase.startsWith("wss://");
}

From source file:Main.java

/**
 * Get the port for mesh usage(For mesh require port hex uppercase).
 * /*from ww  w . j a v  a  2s .  c  om*/
 * @param port the port
 * @return the port for mesh usage
 */
public static String getPortForMesh(int port) {
    String portHexUppercase = Integer.toHexString(port).toUpperCase(Locale.US);
    int numberOfZero = 4 - portHexUppercase.length();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < numberOfZero; i++) {
        sb.append("0");
    }
    sb.append(portHexUppercase);
    return sb.toString();
}

From source file:Main.java

public static String capitalize(String input) {
    return input.toUpperCase(new Locale(Locale.ENGLISH.getLanguage(), Locale.US.getCountry()));
}

From source file:Main.java

public static String hexString(byte[] bytes) {
    StringBuilder val = new StringBuilder();
    for (byte b : bytes) {
        if (b <= 15)
            val.append("0");
        val.append(Integer.toHexString(b & 0xFF));
    }/*w  w w  .j av a 2 s  . com*/
    return val.toString().toLowerCase(Locale.US);
}