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:com.otaupdater.KernelTab.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    cfg = Config.getInstance(getActivity().getApplicationContext());

    HashMap<String, Object> item;

    item = new HashMap<String, Object>();
    item.put(KEY_TITLE, getString(R.string.main_device));
    item.put(KEY_SUMMARY, android.os.Build.DEVICE.toLowerCase(Locale.US));
    item.put(KEY_ICON, R.drawable.ic_device);
    DATA.add(item);/*from w w  w . j a v  a2 s  . c om*/

    item = new HashMap<String, Object>();
    item.put(KEY_TITLE, getString(R.string.main_kernel));
    item.put(KEY_SUMMARY, PropUtils.getKernelVersion());
    item.put(KEY_ICON, R.drawable.ic_info_outline);
    DATA.add(item);

    if (PropUtils.isKernelOtaEnabled()) {
        String kernelVersion = PropUtils.getKernelOtaVersion();
        if (kernelVersion == null)
            kernelVersion = getString(R.string.kernel_version_unknown);
        Date kernelDate = PropUtils.getKernelOtaDate();
        if (kernelDate != null) {
            kernelVersion += " (" + DateFormat.getDateTimeInstance().format(kernelDate) + ")";
        }

        item = new HashMap<String, Object>();
        item.put(KEY_TITLE, getString(R.string.kernel_version));
        item.put(KEY_SUMMARY, kernelVersion);
        item.put(KEY_ICON, R.drawable.ic_settings);
        DATA.add(item);

        item = new HashMap<String, Object>();
        item.put(KEY_TITLE, getString(R.string.main_otaid));
        item.put(KEY_SUMMARY, PropUtils.getKernelOtaID());
        item.put(KEY_ICON, R.drawable.ic_key);
        DATA.add(item);

        item = new HashMap<String, Object>();
        item.put(KEY_TITLE, getString(R.string.updates_avail_title));
        if (cfg.hasStoredKernelUpdate()) {
            KernelInfo info = cfg.getStoredKernelUpdate();
            if (info.isUpdate()) {
                item.put(KEY_SUMMARY, getString(R.string.updates_new, info.name, info.version));
            } else {
                item.put(KEY_SUMMARY, getString(R.string.updates_none));
                cfg.clearStoredKernelUpdate();
            }
        } else {
            item.put(KEY_SUMMARY, getString(R.string.updates_none));
        }
        item.put(KEY_ICON, R.drawable.ic_cloud_download);
        AVAIL_UPDATES_IDX = DATA.size();
        DATA.add(item);
    } else {
        if (cfg.hasStoredKernelUpdate())
            cfg.clearStoredKernelUpdate();

        item = new HashMap<String, Object>();
        item.put(KEY_TITLE, getString(R.string.kernel_unsupported));
        item.put(KEY_SUMMARY, getString(R.string.kernel_unsupported_summary));
        item.put(KEY_ICON, R.drawable.ic_cloud_off);
        DATA.add(item);
    }
}

From source file:net.hillsdon.reviki.web.vcintegration.BasicAuthPassThroughBasicSVNOperationsFactory.java

static UsernamePassword getBasicAuthCredentials(String authorization) {
    String username = null;//  ww w. j ava  2s. c  o  m
    String password = null;
    if (authorization != null) {
        authorization = authorization.trim();
        if (authorization.toLowerCase(Locale.US).startsWith("basic")) {
            int separator = authorization.lastIndexOf(' ');
            if (separator != -1) {
                String token = authorization.substring(separator + 1);
                // RFC2617 doesn't seem to mention encoding...
                try {
                    String usernamePassword = new String(Base64.decodeBase64(token.getBytes("ASCII")));
                    int firstColon = usernamePassword.indexOf(':');
                    if (firstColon != -1) {
                        username = usernamePassword.substring(0, firstColon);
                        password = usernamePassword.substring(firstColon + 1);
                    }
                } catch (IOException e) {
                    // Ignore base64 decode error.
                }
            }
        }
    }
    return new UsernamePassword(username, password);
}

From source file:com.iana.config.IANAAPIApplication.java

@Bean
public LocaleResolver localeResolver() {
    SessionLocaleResolver slr = new SessionLocaleResolver();
    slr.setDefaultLocale(Locale.US);
    return slr;
}

From source file:org.broadleafcommerce.vendor.CyberSourcePaymentServiceTest.java

@Test(groups = { "testSuccessfulCyberSourceCCPayment" })
@Rollback(false)// w w  w  .  j av  a 2  s  . c o  m
public void testSuccessfulCyberSourceCCPayment() throws Exception {
    if (serviceManager.getMerchantId().equals("?")) {
        return;
    }

    System.out.println("***Initiating testSuccessfulCyberSourceCCPayment***");

    /*
     * authorize the amount
     */
    CyberSourceCardRequest cardRequest = new CyberSourceCardRequest();
    cardRequest.setTransactionType(CyberSourceTransactionType.AUTHORIZE);
    cardRequest.setCurrency(Currency.getInstance(Locale.US).getCurrencyCode());

    CyberSourceBillingRequest billingRequest = new CyberSourceBillingRequest();
    billingRequest.setCity("Mountain View");
    billingRequest.setFirstName("John");
    billingRequest.setLastName("Doe");
    billingRequest.setPostalCode("94043");
    billingRequest.setIpAddress("10.7.111.111");
    billingRequest.setState("CA");
    billingRequest.setStreet1("1295 Charleston Road");
    billingRequest.setCountry("US");
    billingRequest.setEmail("null@cybersource.com");

    cardRequest.setBillingRequest(billingRequest);

    CyberSourceItemRequest itemRequest1 = new CyberSourceItemRequest();
    itemRequest1.setDescription("First Item");
    itemRequest1.setQuantity(2L);
    itemRequest1.setShortDescription("firstItem");
    itemRequest1.setUnitPrice(new Money(12.34));

    cardRequest.getItemRequests().add(itemRequest1);

    CyberSourceItemRequest itemRequest2 = new CyberSourceItemRequest();
    itemRequest2.setDescription("Second Item");
    itemRequest2.setQuantity(1L);
    itemRequest2.setShortDescription("secondItem");
    itemRequest2.setUnitPrice(new Money(56.78));

    cardRequest.getItemRequests().add(itemRequest2);

    cardRequest.setAccountNumber("4111111111111111");
    cardRequest.setExpirationMonth(12);
    cardRequest.setExpirationYear(2020);

    CyberSourcePaymentService service = (CyberSourcePaymentService) serviceManager.getValidService(cardRequest);
    CyberSourceCardResponse response = (CyberSourceCardResponse) service.process(cardRequest);

    assert (response.getAuthResponse().getAmount().doubleValue() > 0D);
    assert (response.getReasonCode().intValue() == 100);

    /*cardRequest.setAccountNumber("12345");
    CyberSourceCardResponse rejectResponse = (CyberSourceCardResponse) service.process(cardRequest);
    assert(rejectResponse.isErrorDetected());
            
    cardRequest.setAccountNumber("4111111111111111");
    cardRequest.getBillingRequest().setLastName(null);
    PaymentException hostException = null;
    try {
    service.process(cardRequest);
    } catch (PaymentException e) {
    hostException = e;
    }
    assert(hostException != null && hostException instanceof PaymentHostException);
    cardRequest.getBillingRequest().setLastName("Doe");*/

    /*
     * capture
     */
    CyberSourceCardRequest cardRequest2 = new CyberSourceCardRequest();
    cardRequest2.setTransactionType(CyberSourceTransactionType.CAPTURE);
    cardRequest2.setCurrency(Currency.getInstance(Locale.US).getCurrencyCode());
    cardRequest2.setRequestID(response.getRequestID());
    cardRequest2.setRequestToken(response.getRequestToken());
    cardRequest2.getItemRequests().add(itemRequest1);
    cardRequest2.getItemRequests().add(itemRequest2);

    CyberSourceCardResponse response2 = (CyberSourceCardResponse) service.process(cardRequest2);

    assert (response2.getReasonCode().intValue() == 100);

    /*
     * authorize and capture
     */
    cardRequest.setTransactionType(CyberSourceTransactionType.AUTHORIZEANDCAPTURE);
    CyberSourceCardResponse response3 = (CyberSourceCardResponse) service.process(cardRequest);

    assert (response3.getAuthResponse().getAmount().doubleValue() > 0D);
    assert (response3.getCaptureResponse().getAmount().doubleValue() > 0D);
    assert (response3.getReasonCode().intValue() == 100);

    /*
     * credit
     */
    CyberSourceCardRequest cardRequest4 = new CyberSourceCardRequest();
    cardRequest4.setTransactionType(CyberSourceTransactionType.CREDIT);
    cardRequest4.setCurrency(Currency.getInstance(Locale.US).getCurrencyCode());
    cardRequest4.setRequestID(response3.getRequestID());
    cardRequest4.setRequestToken(response3.getRequestToken());
    cardRequest4.getItemRequests().add(itemRequest1);
    cardRequest4.getItemRequests().add(itemRequest2);

    CyberSourceCardResponse response4 = (CyberSourceCardResponse) service.process(cardRequest4);

    assert (response4.getReasonCode().intValue() == 100);

    /*
     * void
     */
    //TODO does not appear to be working in the CyberSource test environment
    /*
    cardRequest.setTransactionType(CyberSourceTransactionType.AUTHORIZEANDCAPTURE);
    CyberSourceCardResponse response5 = (CyberSourceCardResponse) service.process(cardRequest);
            
    CyberSourceCardRequest cardRequest6 = new CyberSourceCardRequest();
    cardRequest6.setTransactionType(CyberSourceTransactionType.VOIDTRANSACTION);
    cardRequest6.setServiceType(CyberSourceServiceType.PAYMENT);
    cardRequest6.setMethodType(CyberSourceMethodType.CREDITCARD);
    cardRequest6.setCurrency(Currency.getInstance(Locale.US).getCurrencyCode());
    cardRequest6.setRequestID(response5.getRequestID());
    cardRequest6.setRequestToken(response5.getRequestToken());
            
    CyberSourceCardResponse response6 = (CyberSourceCardResponse) service.process(cardRequest6);
            
    assert(response6.getReasonCode().intValue() == 100);
    */

    /*
     * reverse authorize
     */
    cardRequest.setTransactionType(CyberSourceTransactionType.AUTHORIZE);
    CyberSourceCardResponse response7 = (CyberSourceCardResponse) service.process(cardRequest);

    CyberSourceCardRequest cardRequest7 = new CyberSourceCardRequest();
    cardRequest7.setTransactionType(CyberSourceTransactionType.REVERSEAUTHORIZE);
    cardRequest7.setCurrency(Currency.getInstance(Locale.US).getCurrencyCode());
    cardRequest7.setRequestID(response7.getRequestID());
    cardRequest7.setRequestToken(response7.getRequestToken());
    cardRequest7.getItemRequests().add(itemRequest1);
    cardRequest7.getItemRequests().add(itemRequest2);

    CyberSourceCardResponse response8 = (CyberSourceCardResponse) service.process(cardRequest7);

    assert (response8.getReasonCode().intValue() == 100);
}

From source file:com.otaupdater.ROMTab.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    cfg = Config.getInstance(getActivity().getApplicationContext());

    HashMap<String, Object> item;

    item = new HashMap<String, Object>();
    item.put(KEY_TITLE, getString(R.string.main_device));
    item.put(KEY_SUMMARY, android.os.Build.DEVICE.toLowerCase(Locale.US));
    item.put(KEY_ICON, R.drawable.ic_device);
    DATA.add(item);// w w w  .  j a  v  a  2s  .c o  m

    item = new HashMap<String, Object>();
    item.put(KEY_TITLE, getString(R.string.main_rom));
    item.put(KEY_SUMMARY, android.os.Build.DISPLAY);
    item.put(KEY_ICON, R.drawable.ic_info_outline);
    DATA.add(item);

    String romVersion = PropUtils.getRomOtaVersion();
    if (romVersion == null)
        romVersion = PropUtils.getRomVersion();

    if (PropUtils.isRomOtaEnabled()) {
        Date romDate = PropUtils.getRomOtaDate();
        if (romDate != null) {
            romVersion += " (" + DateFormat.getDateTimeInstance().format(romDate) + ")";
        }

        item = new HashMap<String, Object>();
        item.put(KEY_TITLE, getString(R.string.rom_version));
        item.put(KEY_SUMMARY, romVersion);
        item.put(KEY_ICON, R.drawable.ic_settings);
        DATA.add(item);

        item = new HashMap<String, Object>();
        item.put(KEY_TITLE, getString(R.string.main_otaid));
        item.put(KEY_SUMMARY, PropUtils.getRomOtaID());
        item.put(KEY_ICON, R.drawable.ic_key);
        DATA.add(item);

        item = new HashMap<String, Object>();
        item.put(KEY_TITLE, getString(R.string.updates_avail_title));
        if (cfg.hasStoredRomUpdate()) {
            RomInfo info = cfg.getStoredRomUpdate();
            if (info.isUpdate()) {
                item.put(KEY_SUMMARY, getString(R.string.updates_new, info.name, info.version));
            } else {
                item.put(KEY_SUMMARY, getString(R.string.updates_none));
                cfg.clearStoredRomUpdate();
            }
        } else {
            item.put(KEY_SUMMARY, getString(R.string.updates_none));
        }
        item.put(KEY_ICON, R.drawable.ic_cloud_download);
        AVAIL_UPDATES_IDX = DATA.size();
        DATA.add(item);
    } else {
        if (cfg.hasStoredRomUpdate())
            cfg.clearStoredRomUpdate();

        if (!romVersion.equals(Build.DISPLAY)) {
            item = new HashMap<String, Object>();
            item.put(KEY_TITLE, getString(R.string.rom_version));
            item.put(KEY_SUMMARY, romVersion);
            item.put(KEY_ICON, R.drawable.ic_settings);
            DATA.add(item);
        }

        item = new HashMap<String, Object>();
        item.put(KEY_TITLE, getString(R.string.rom_unsupported));
        item.put(KEY_SUMMARY, getString(R.string.rom_unsupported_summary));
        item.put(KEY_ICON, R.drawable.ic_cloud_off);
        DATA.add(item);
    }
}

From source file:org.thymeleaf.spring3.view.ThymeleafViewResolverTest.java

@Test
public void testConfigureViewNoBean() throws Exception {

    final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "classpath:spring3/view/applicationContext.xml");

    final ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setApplicationContext(context);
    resolver.setViewClass(TestThymeleafView.class);

    // testview2 does not exist as a declared bean at the application context
    final View view = resolver.loadView("testview2", Locale.US);

    // There's no matching view definition, so "something" should not be populated
    final String viewValue = ((TestThymeleafView) view).getSomething();
    Assert.assertNull(viewValue);/*  w ww .  ja v a2  s.c  o  m*/

    final TestThymeleafView.ViewBean viewBean = ((TestThymeleafView) view).getViewBean();
    Assert.assertNotNull(viewBean);

    // This should be there, because it is applied through an @Autowired annotation
    final String beanValue = viewBean.getValue();
    Assert.assertEquals("bean_value", beanValue);

}

From source file:org.thymeleaf.spring4.view.ThymeleafViewResolverTest.java

@Test
public void testConfigureViewNoBean() throws Exception {

    final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "classpath:spring4/view/applicationContext.xml");

    final ThymeleafViewResolver resolver = new ThymeleafViewResolver();
    resolver.setApplicationContext(context);
    resolver.setViewClass(TestThymeleafView.class);

    // testview2 does not exist as a declared bean at the application context
    final View view = resolver.loadView("testview2", Locale.US);

    // There's no matching view definition, so "something" should not be populated
    final String viewValue = ((TestThymeleafView) view).getSomething();
    Assert.assertNull(viewValue);//w w w  .j a  v a 2 s . co m

    final TestThymeleafView.ViewBean viewBean = ((TestThymeleafView) view).getViewBean();
    Assert.assertNotNull(viewBean);

    // This should be there, because it is applied through an @Autowired annotation
    final String beanValue = viewBean.getValue();
    Assert.assertEquals("bean_value", beanValue);

}

From source file:com.acrutiapps.browser.tasks.HistoryBookmarksExportTask.java

/**
 * Get a string representation of the current date / time in a format suitable for a file name.
 * @return A string representation of the current date / time.
 *//*w  w  w.  j a v a  2  s . c om*/
private String getNowForFileName() {
    Calendar c = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.US);

    return sdf.format(c.getTime());
}

From source file:com.ratebeer.android.api.command.GetRatingsCommand.java

@Override
protected void parse(JSONArray json) throws JSONException {
    SimpleDateFormat dateFormat = new SimpleDateFormat("M/d/yyyy h:mm:ss a", Locale.US);
    ratings = new ArrayList<BeerRating>();
    for (int i = 0; i < json.length(); i++) {
        JSONObject result = json.getJSONObject(i);
        String entered = result.getString("TimeEntered");
        Date timeEntered = null;//from  w  w  w . j ava  2s. c o  m
        try {
            timeEntered = dateFormat.parse(entered);
        } catch (ParseException e) {
        }
        String updated = result.getString("TimeUpdated");
        Date timeUpdated = null;
        try {
            timeUpdated = dateFormat.parse(updated);
        } catch (ParseException e) {
        }
        int stateID = NO_STATE;
        if (!result.getString("StateID").equals("null")) {
            stateID = Integer.parseInt(result.getString("StateID"));
        }
        ratings.add(new BeerRating(result.getInt("RatingID"), result.getInt("Appearance"),
                result.getInt("Aroma"), result.getInt("Flavor"), result.getInt("Mouthfeel"),
                result.getInt("Overall"), result.getString("TotalScore"),
                HttpHelper.cleanHtml(result.getString("Comments")), timeEntered, timeUpdated,
                result.getInt("UserID"), HttpHelper.cleanHtml(result.getString("UserName")),
                HttpHelper.cleanHtml(result.getString("City")), stateID,
                (result.has("State") ? HttpHelper.cleanHtml(result.getString("State")) : ""),
                result.getInt("CountryID"),
                (result.has("Country") ? HttpHelper.cleanHtml(result.getString("Country")) : ""),
                result.getInt("RateCount")));
    }

}

From source file:ru.mystamps.web.service.ImageServiceImpl.java

@Override
@Transactional/*from  w  w  w . java2  s. c om*/
@PreAuthorize("isAuthenticated()")
public Integer save(MultipartFile file) {
    Validate.isTrue(file != null, "File must be non null");
    Validate.isTrue(file.getSize() > 0, "Image size must be greater than zero");

    String contentType = file.getContentType();
    Validate.isTrue(contentType != null, "File type must be non null");

    String extension = extractExtensionFromContentType(contentType);
    Validate.validState("png".equals(extension) || "jpeg".equals(extension),
            "File type must be PNG or JPEG image, but '%s' (%s) were passed", contentType, extension);

    String imageType = extension.toUpperCase(Locale.US);

    Integer id = imageDao.add(imageType);
    if (id == null) {
        throw new ImagePersistenceException("Can't save image");
    }

    ImageInfoDto image = new ImageInfoDto(id, imageType);
    LOG.info("Image was saved to database ({})", image);

    imagePersistenceStrategy.save(file, image);

    return image.getId();
}