List of usage examples for java.util Locale US
Locale US
To view the source code for java.util Locale US.
Click Source Link
From source file:com.wellsandwhistles.android.redditsp.reddit.things.RedditSubreddit.java
public String getKey() { try {/*w w w . j a v a 2s . c om*/ return getCanonicalName(); } catch (InvalidSubredditNameException e) { throw new UnexpectedInternalStateException(String.format(Locale.US, "Cannot save subreddit '%s'", url)); } }
From source file:com.consumerkarma.TTS.SpeechAuth.java
/** * Sets up an OAuth client credentials authentication. * Follow this with a call to fetchTo() to actually load the data. * @param oauthService the URL of the OAuth client credentials service * @param apiKey the OAuth client ID//w w w . j a v a2 s . c o m * @param apiSecret the OAuth client secret * @throws IllegalArgumentException for bad URL, etc. **/ public static SpeechAuth forService(String oauthService, String apiKey, String apiSecret) throws IllegalArgumentException { try { URL url = new URL(oauthService); HttpURLConnection request = (HttpURLConnection) url.openConnection(); String data = String.format(Locale.US, OAUTH_DATA, apiKey, apiSecret); byte[] bytes = data.getBytes("UTF8"); request.setConnectTimeout(CONNECT_TIMEOUT); request.setReadTimeout(READ_TIMEOUT); return new SpeechAuth(request, bytes); } catch (IOException e) { throw new IllegalArgumentException(e); } catch (ClassCastException e) { throw new IllegalArgumentException("URL must be HTTP: " + oauthService, e); } }
From source file:com.att.ads.sample.SpeechAuth.java
/** * Sets up an OAuth client credentials authentication. * Follow this with a call to fetchTo() to actually load the data. * @param oauthService the URL of the OAuth client credentials service * @param apiKey the OAuth client ID/*from w w w.j ava 2s . c o m*/ * @param apiSecret the OAuth client secret * @throws IllegalArgumentException for bad URL, etc. **/ public static SpeechAuth forService(String oauthService, String oauthScope, String apiKey, String apiSecret) throws IllegalArgumentException { try { URL url = new URL(oauthService); HttpURLConnection request = (HttpURLConnection) url.openConnection(); String data = String.format(Locale.US, OAUTH_DATA, oauthScope, apiKey, apiSecret); byte[] bytes = data.getBytes("UTF8"); request.setConnectTimeout(CONNECT_TIMEOUT); request.setReadTimeout(READ_TIMEOUT); return new SpeechAuth(request, bytes); } catch (IOException e) { throw new IllegalArgumentException(e); } catch (ClassCastException e) { throw new IllegalArgumentException("URL must be HTTP: " + oauthService, e); } }
From source file:org.atomserver.core.dbstore.dao.ContentDAOTest.java
public void testContentDAO() throws Exception { EntryDescriptor entry = new BaseEntryDescriptor("widgets", "acme", "16661", Locale.US); entriesDAO.ensureCollectionExists(entry.getWorkspace(), entry.getCollection()); entriesDAO.insertEntry(entry);/*from w w w. jav a 2 s .c o m*/ EntryMetaData entryMetaData = entriesDAO.selectEntry(entry); assertFalse(contentDAO.contentExists(entryMetaData)); assertEquals(null, contentDAO.selectContent(entryMetaData)); contentDAO.putContent(entryMetaData, "<content/>"); assertTrue(contentDAO.contentExists(entryMetaData)); assertEquals("<content/>", contentDAO.selectContent(entryMetaData)); contentDAO.putContent(entryMetaData, "<newcontent/>"); assertTrue(contentDAO.contentExists(entryMetaData)); assertEquals("<newcontent/>", contentDAO.selectContent(entryMetaData)); contentDAO.deleteContent(entryMetaData); assertFalse(contentDAO.contentExists(entryMetaData)); assertEquals(null, contentDAO.selectContent(entryMetaData)); entriesDAO.obliterateEntry(entry); try { contentDAO.putContent(entryMetaData, "<content/>"); assertTrue("expected an exception to be thrown!", false); } catch (DataIntegrityViolationException e) { // do nothing - we expect this! } }
From source file:com.clustercontrol.util.HinemosTime.java
/** * Hinemos??HinemosManager?????<br> * @return/*from w w w .j a v a2 s.c om*/ */ public static String getDateString() { SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss XXX yyyy", Locale.US); sdf.setTimeZone(HinemosTime.getTimeZone()); return sdf.format(currentTimeMillis()); }
From source file:com.legstar.mock.client.MockVararcom.java
/** * @return a hexadecimal representation of host data. *///www .j a v a 2s .com public static String getHostBytesHex36() { StringBuilder sb = new StringBuilder("0024"); for (int i = 0; i < 36; i++) { StringBuilder sbl = new StringBuilder(); Formatter formatter = new Formatter(sbl, Locale.US); formatter.format("%04x", 5 * (i + 1)); sb.append("c6c7c8c9d1" + sbl.toString()); } return sb.toString(); }
From source file:org.jmesa.core.message.MessagesTest.java
@Test public void getPreference() { MockHttpServletRequest request = new MockHttpServletRequest(); WebContext webContext = new HttpServletRequestWebContext(request); webContext.setLocale(Locale.US); Messages messages = new ResourceBundleMessages("org.jmesa.core.message.testResourceBundle", webContext); String message = messages.getMessage("test.normal"); assertNotNull(message);//from www . ja va 2s.c om assertTrue(message.equals("foo")); message = messages.getMessage("test.args", new String[] { "1" }); assertNotNull(message); assertTrue(message.equals("foo 1")); }
From source file:com.octo.captcha.engine.bufferedengine.SimpleBufferedEngineContainerTest.java
public void testExecute() throws Exception { Resource ressource = new ClassPathResource("testSimpleBufferedEngine.xml"); ConfigurableBeanFactory bf = new XmlBeanFactory(ressource); BufferedEngineContainer container = (BufferedEngineContainer) bf.getBean("container"); Thread.sleep(8000);//from w w w .ja va 2 s. c o m for (int i = 0; i < 30; i++) { assertNotNull(container.getNextCaptcha(Locale.US)); } Thread.sleep(4000); ((SimpleBufferedEngineContainer) container).stopDaemon(); }
From source file:Main.java
private static String getCaller(String tag) { String caller = "<unknown>"; StackTraceElement[] trace = new Throwable().fillInStackTrace().getStackTrace(); if (trace.length < 6) { return caller; }// ww w . j a v a 2 s . c o m // Walk up the stack looking for the first caller outside of LogUtils. // It will be at least 5 frames up, so start there. for (int i = 5; i < trace.length; i++) { // Class<?> clazz = trace[i].getClass(); String clazzName = trace[i].getClassName(); if (!clazzName.contains("Log")) { String callingClass = clazzName; callingClass = callingClass.substring(callingClass.lastIndexOf('.') + 1); callingClass = callingClass.substring(callingClass.lastIndexOf('$') + 1); caller = callingClass + "." + trace[i].getMethodName(); break; } } return String.format(Locale.US, "[%d/%s] %s %s: %s", Thread.currentThread().getId(), Thread.currentThread().getName(), LOG_PREFIX, tag, caller); }
From source file:org.thymeleaf.engine21.conversion.conversion3.LongFormatter.java
public Long parse(final String text, final Locale locale) throws ParseException { final NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US); return Long.valueOf(numberFormat.parse(text).longValue()); }