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:cc.kave.commons.pointsto.evaluation.ProjectTrainValidateEvaluation.java

public static void main(String[] args) throws IOException {
    Locale.setDefault(Locale.US);

    Path baseDir = Paths.get("E:\\Coding\\MT");
    Path usageStoresDir = baseDir.resolve("Usages");
    Path resultFile = baseDir.resolve("EvaluationResults").resolve("TrainValidate.txt");

    ProjectTrainValidateEvaluation evaluator = INJECTOR.getInstance(ProjectTrainValidateEvaluation.class);
    evaluator.run(usageStoresDir);/*www.  j a  v a2  s  .c  om*/

    INJECTOR.getInstance(ResultExporter.class).export(resultFile, evaluator.getResults().entrySet().stream()
            .flatMap(e -> e.getValue().stream().map(er -> ImmutablePair.of(e.getKey(), er))).map(p -> {
                return new String[] { CoReNames.vm2srcQualifiedType(p.left), p.right.training,
                        p.right.validation, String.format(Locale.US, "%.3f", p.right.score),
                        Integer.toString(p.right.numTrainingUsages),
                        Integer.toString(p.right.numValidationUsages) };
            }));

    INJECTOR.getInstance(ExecutorService.class).shutdown();
}

From source file:Main.java

public static Date getExifDate(File imgFile) throws IOException {
    ExifInterface imgFileExif = new ExifInterface(imgFile.getCanonicalPath());

    if (imgFileExif.getAttribute(ExifInterface.TAG_DATETIME) != null) {
        String imgDateTime = imgFileExif.getAttribute(ExifInterface.TAG_DATETIME);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", Locale.US);

        try {/*from  ww  w .  ja va  2  s . c o m*/
            return simpleDateFormat.parse(imgDateTime);

        } catch (ParseException e) {
            e.printStackTrace();
        }
    }

    return null;
}

From source file:Main.java

public static final String bytesToHexString(byte[] bArray) {
    StringBuffer sb = new StringBuffer(bArray.length);

    for (int i = 0; i < bArray.length; i++) {
        String sTemp = Integer.toHexString(0xFF & bArray[i]);
        if (sTemp.length() < 2) {
            sb.append(0);//from   www  .ja  v  a2  s. c  o m
        }
        sb.append(sTemp.toUpperCase(Locale.US));
    }
    return sb.toString();
}

From source file:com.infullmobile.jenkins.plugin.restrictedregister.util.AppUrls.java

@Nonnull
public static String buildActivationUrl(String code, String secret) throws InvalidUriException {
    String ret = null;//from ww  w. ja  v a2  s .  c  o m
    final String path = String.format(Locale.US, FORMAT_REGISTER_PATH,
            PluginModule.getDefault().getPluginDescriptor().getRootActionURL());
    try {
        final URIBuilder builder = new URIBuilder(getRootURL());
        builder.setPath(path);
        builder.addParameter(BaseFormField.SECRET.getFieldName(), secret);
        builder.addParameter(BaseFormField.ACTIVATION_CODE.getFieldName(), code);
        final URI uri = builder.build();
        ret = uri.toURL().toExternalForm();
    } catch (URISyntaxException | MalformedURLException e) {
        onError(e.getLocalizedMessage());
    }
    return ret;
}

From source file:Main.java

/**
 * Formats a birthday date to a String    
 * @param bDay date in <i>"mm/dd/yyyy"</i> format
 * @return formated date string </br><b>Format : </b> "yyyy-MM-dd HH:mm:ss" 
 *//*from www . j  a  v  a 2 s  .co m*/
public static String formatDate(String bDay) {
    Calendar calDob = Calendar.getInstance();
    String formated = "";
    if (bDay != null) {
        String[] mmddyyyy = bDay.split("/");
        if (mmddyyyy.length == 3) {
            calDob.set(calDob.get(Calendar.YEAR), Integer.parseInt(mmddyyyy[0]) - 1,
                    Integer.parseInt(mmddyyyy[1]), 23, 59, 59);
        } else if (mmddyyyy.length == 2) {
            calDob.set(calDob.get(Calendar.YEAR), Integer.parseInt(mmddyyyy[0]) - 1,
                    Integer.parseInt(mmddyyyy[1]), 23, 59, 59);
        }
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
        dateFormat.setCalendar(calDob);
        formated = dateFormat.format(calDob.getTime());
    }
    return formated;
}

From source file:Main.java

/**
 * Formats a birthday date to a String    
 * @param bDay date in <i>"yyyy-mm-dd"</i> format
 * @return formated date string </br><b>Format : </b> "yyyy-MM-dd HH:mm:ss" 
 *//*from   www .  j  a  va 2  s  .com*/
public static String formatContactDate(String bDay) {
    Calendar calDob = Calendar.getInstance();
    String formated = "";
    if (bDay != null) {
        String[] mmddyyyy = bDay.split("-");
        if (mmddyyyy.length == 3) {
            calDob.set(calDob.get(Calendar.YEAR), Integer.parseInt(mmddyyyy[1]) - 1,
                    Integer.parseInt(mmddyyyy[2]), 23, 59, 59);
        } else if (mmddyyyy.length == 2) {
            calDob.set(calDob.get(Calendar.YEAR), Integer.parseInt(mmddyyyy[1]) - 1,
                    Integer.parseInt(mmddyyyy[2]), 23, 59, 59);
        }
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
        dateFormat.setCalendar(calDob);
        formated = dateFormat.format(calDob.getTime());
    }
    return formated;
}

From source file:Main.java

/**
 * Get a fragment in a {@link ViewPager}s adapter.
 *
 * @param manager//from w w w .j a va2 s.c  o  m
 *     the support fragment manager.
 *     {@link android.support.v4.app.FragmentActivity#getSupportFragmentManager()}
 * @param pager
 *     the {@link ViewPager} holding the {@link android.support.v4.app.Fragment}
 * @param position
 *     the position in the {@link ViewPager} e.g. {@link ViewPager#getCurrentItem()}
 * @param <fragment>
 *     Destination cast class type.
 * @return the fragment at this position in the {@link ViewPager}'s adapter
 */
@SuppressWarnings("unchecked")
public static <fragment extends android.support.v4.app.Fragment> fragment findFragmentByPosition(
        android.support.v4.app.FragmentManager manager, ViewPager pager, int position) {
    return (fragment) manager
            .findFragmentByTag(String.format(Locale.US, FRAGMENT_ADAPTER_ID, pager.getId(), position));
}

From source file:by.stub.utils.StringUtils.java

public static String toUpper(final String toUpper) {
    if (!isSet(toUpper)) {
        return null;
    }//from  w  w  w  . j a  va  2s.c  o  m
    return toUpper.toUpperCase(Locale.US);
}

From source file:com.QuarkLabs.BTCeClient.exchangeApi.App.java

/**
 * Gets info for provided pairs/*from www.j av  a  2s .co  m*/
 *
 * @param pairs Array of pairs to get info for
 * @return JSONObject with data, sample https://btc-e.com/api/3/ticker/btc_usd-btc_rur
 * @throws JSONException
 */
public static JSONObject getPairInfo(String[] pairs) throws JSONException {
    String url = "https://btc-e.com/api/3/ticker/";
    for (String x : pairs) {
        url += x.replace("/", "_").toLowerCase(Locale.US) + "-";
    }
    SimpleRequest reqSim = new SimpleRequest();
    return reqSim.makeRequest(url.substring(0, url.length() - 1));
}

From source file:com.esofthead.mycollab.configuration.LocaleHelper.java

public static IDateFormat getDateFormatInstance(Locale locale) {
    IDateFormat dateFormat = dateFormats.get(locale);
    if (dateFormat == null) {
        dateFormat = dateFormats.get(Locale.US);
    }//from  w ww  . j  a va  2 s. c  om
    return dateFormat;
}