List of usage examples for java.util Locale ENGLISH
Locale ENGLISH
To view the source code for java.util Locale ENGLISH.
Click Source Link
From source file:com.carlomicieli.jtrains.value.objects.LocalizedFieldSerializationTests.java
@Test public void shouldDeserializeLocalizedFieldsContainNumbers() throws IOException { LocalizedField<Integer> field = parseLocalizedField("{\"en\": 24, \"it\": 42}", Integer.class); assertThat(field).hasSize(2).containsEntry(Locale.ENGLISH, 24).containsEntry(Locale.ITALIAN, 42); }
From source file:org.obiba.mica.core.domain.LocalizedStringTest.java
@Test public void test_localized_string_to_json() throws Exception { LocalizedString string = new LocalizedString().forLanguageTag(null, "coucou").forEn("kewkew"); String json = objectMapper.writeValueAsString(string); log.debug(string.toString());//from w w w . ja va 2 s .c om log.debug(json); assertThat(string.keySet().contains(Locale.ENGLISH.toLanguageTag())).isTrue(); assertThat(string.keySet().contains(Locale.forLanguageTag("und").toLanguageTag())).isTrue(); LocalizedString string2 = objectMapper.readValue(json, LocalizedString.class); log.debug(string2.toString()); assertThat(string2.keySet().contains(Locale.ENGLISH.toLanguageTag())).isTrue(); assertThat(string2.keySet().contains(Locale.forLanguageTag("und").toLanguageTag())).isTrue(); }
From source file:io.crate.rest.AdminUIIntegrationTest.java
private URI adminURI() throws URISyntaxException { return new URI(String.format(Locale.ENGLISH, "http://%s:%d/", address.getHostName(), address.getPort())); }
From source file:cn.org.awcp.core.utils.DateUtils.java
/** * ?<br>/*from w w w . j av a 2 s . c o m*/ * ??<br> * generate by: vakin jiang at 2012-3-1 * * @param dateStr * @return */ public static Date parseDate(String dateStr) { SimpleDateFormat format = null; if (StringUtils.isBlank(dateStr)) { return null; } String _dateStr = dateStr.trim(); try { if (_dateStr.matches("\\d{1,2}[A-Z]{3}")) { _dateStr = _dateStr + (Calendar.getInstance().get(Calendar.YEAR) - 2000); } // 01OCT12 if (_dateStr.matches("\\d{1,2}[A-Z]{3}\\d{2}")) { format = new SimpleDateFormat("ddMMMyy", Locale.ENGLISH); } else if (_dateStr.matches("\\d{1,2}[A-Z]{3}\\d{4}.*")) {// 01OCT2012 // ,01OCT2012 // 1224,01OCT2012 // 12:24 _dateStr = _dateStr.replaceAll("[^0-9A-Z]", "").concat("000000").substring(0, 15); format = new SimpleDateFormat("ddMMMyyyyHHmmss", Locale.ENGLISH); } else { StringBuffer sb = new StringBuffer(_dateStr); String[] tempArr = _dateStr.split("\\s+"); tempArr = tempArr[0].split("-|\\/"); if (tempArr.length == 3) { if (tempArr[1].length() == 1) { sb.insert(5, "0"); } if (tempArr[2].length() == 1) { sb.insert(8, "0"); } } _dateStr = sb.append("000000").toString().replaceAll("[^0-9]", "").substring(0, 14); if (_dateStr.matches("\\d{14}")) { format = new SimpleDateFormat("yyyyMMddHHmmss"); } } Date date = format.parse(_dateStr); return date; } catch (Exception e) { throw new RuntimeException("?[" + dateStr + "]"); } }
From source file:com.ning.maven.plugins.dependencyversionscheck.strategy.DefaultStrategyProvider.java
public Map getStrategies() { if (resolvers == null) { Map newResolvers = new HashMap(); if (!CollectionUtils.isEmpty(resolverDefinitions)) { for (Iterator it = resolverDefinitions.iterator(); it.hasNext();) { final Strategy resolver = (Strategy) it.next(); final String name = resolver.getName().toLowerCase(Locale.ENGLISH); LOG.debug("Adding {} as resolver.", name); newResolvers.put(name, resolver); }//from w w w.j a v a 2 s .co m } resolvers = newResolvers; } return resolvers; }
From source file:httpscheduler.GenericRequestHandler.java
@Override public void handle(final HttpRequest request, final HttpResponse response, final HttpContext context) throws HttpException, IOException { String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH); if (!method.equals("GET") && !method.equals("HEAD") && !method.equals("POST")) { throw new MethodNotSupportedException(method + " method not supported"); }//from ww w.j a va 2 s.c o m StringEntity stringEntity; if (request instanceof HttpEntityEnclosingRequest) { HttpEntity httpEntity = ((HttpEntityEnclosingRequest) request).getEntity(); String entity = EntityUtils.toString(httpEntity); //System.out.println("Incoming entity content (string): " + entity); // Set scheduling policy SchedulingPolicy policy = null; switch (mode) { case "random": policy = new RandomSchedulingPolicy(); break; case "per-task": policy = new PerTaskSamplingSchedulingPolicy(); break; case "batch": policy = new BatchSamplingSchedulingPolicy(); break; default: throw new IllegalArgumentException("Invalid mode: " + mode); } ArrayList<Task> tasksList; Job job; switch (mode) { case "random": case "per-task": tasksList = parseGenericHttpClientRequest(entity); for (Task taskToProcess : tasksList) { Runnable taskSubmitThread = new TaskSubmitThread(taskToProcess, policy); commExecutor.execute(taskSubmitThread); } break; case "batch": job = parseBatchSamplingHttpClientRequest(entity); Runnable jobSubmitThread = new JobSubmitThread(job, policy); commExecutor.execute(jobSubmitThread); break; } response.setStatusCode(HttpStatus.SC_OK); stringEntity = new StringEntity("result:success"); // Create communication thread //SendTaskThread[] threads = new SendTaskThread[tasksList.size()]; //System.out.println("number of send task threads: " + threads.length); } else { response.setStatusCode(HttpStatus.SC_OK); stringEntity = new StringEntity("result:fail"); } response.setEntity(stringEntity); }
From source file:com.sk89q.craftbook.sponge.mechanics.area.complex.CopyManager.java
/** * Load a copy from disk. This may return a cached copy. If the copy is not cached, * the file will be loaded from disk if possible. If the copy * does not exist, an exception will be raised. An exception may be raised if the file exists but cannot be read * for whatever reason./* ww w .jav a2 s . c o m*/ * * @param world The world to load it into * @param namespace The namespace * @param id The area ID * * @return The CuboidCopy * * @throws CuboidCopyException Thrown if the data was invalid */ public static CuboidCopy load(World world, String namespace, String id) throws CuboidCopyException { id = id.toLowerCase(Locale.ENGLISH); File folder = new File(new File(CraftBookPlugin.inst().getWorkingDirectory(), "areas"), namespace); return CuboidCopy.load(new File(folder, id + getFileSuffix()), world); }
From source file:net.daboross.bukkitdev.commandexecutorbase.SubCommand.java
public SubCommand(String commandName, boolean canConsoleExecute, String permission, String helpMessage) { Validate.notNull(commandName);/* w w w. j a v a 2 s . co m*/ this.commandName = commandName.toLowerCase(Locale.ENGLISH); this.help = (helpMessage == null ? "" : helpMessage); this.permission = permission; this.argumentNames = new ArrayList<>(); this.commandFilters = new ArrayList<>(); this.helpConditions = new ArrayList<>(); this.helpConditions.add(new PermissionCondition()); this.commandFilters.add(new PermissionFilter()); if (!canConsoleExecute) { this.helpConditions.add(new PlayerOnlyCondition()); this.commandFilters.add(new PlayerOnlyFilter()); } }
From source file:com.example.app.profile.service.ProfileTypeKindLabelProvider.java
@Nonnull @Override/*from w w w.j a v a 2 s . c om*/ protected TransientLocalizedObjectKey getDefaultName() { TransientLocalizedObjectKey defaultName = new TransientLocalizedObjectKey(new HashMap<>()); defaultName.addLocalization(Locale.ENGLISH, "Profile Type Kind"); return defaultName; }
From source file:com.tesora.dve.charset.NativeCollationCatalogImpl.java
@Override public void addCollation(NativeCollation nc) { collationsByName.put(nc.getName().toUpperCase(Locale.ENGLISH), nc); collationsById.put(nc.getId(), nc);//from w ww . j a v a 2 s .c o m List<NativeCollation> collations = collationsByCharsetName .get(nc.getCharacterSetName().toUpperCase(Locale.ENGLISH)); if (collations == null) { collations = new ArrayList<NativeCollation>(); collationsByCharsetName.put(nc.getCharacterSetName().toUpperCase(Locale.ENGLISH), collations); } collations.add(nc); }