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:net.sf.dynamicreports.test.jasper.chart.ShowValuesChartDataTest.java
@Override protected void configureReport(JasperReportBuilder rb) { TextColumnBuilder<String> column1; TextColumnBuilder<Integer> column2; TextColumnBuilder<Integer> column3; TextColumnBuilder<Date> column4; Locale.setDefault(Locale.ENGLISH); rb.setPageFormat(PageType.A2, PageOrientation.PORTRAIT) .columns(column1 = col.column("Column1", "field1", String.class), column2 = col.column("Column2", "field2", Integer.class), column3 = col.column("Column3", "field3", Integer.class), column4 = col.column("Column4", "field4", Date.class)) .summary(cmp.horizontalList( cht.barChart().setShowValues(true).setCategory(column1).series(cht.serie(column2), cht.serie(column3)), cht.bar3DChart().setShowValues(true).setValuePattern("#,##0.#").setCategory(column1) .series(cht.serie(column2), cht.serie(column3)), cht.stackedBarChart().setShowValues(true).setCategory(column1).series(cht.serie(column2), cht.serie(column3)), cht.stackedBar3DChart().setShowValues(true).setCategory(column1).series(cht.serie(column2), cht.serie(column3))), cmp.horizontalList(//from w w w. j a v a 2 s . c o m cht.areaChart().setShowValues(true).setCategory(column1).series(cht.serie(column3), cht.serie(column2)), cht.lineChart().setShowValues(true).setCategory(column1).series(cht.serie(column2), cht.serie(column3)), cht.groupedStackedBarChart().setShowValues(true).setCategory(column1) .series(cht.groupedSerie(column2).setGroup(column1).setSeries(column1))), cmp.horizontalList( cht.pieChart().setShowValues(true).setKey(column1).series(cht.serie(column2)), cht.pie3DChart().setShowValues(true).setValuePattern("#,##0.#").setKey(column1) .series(cht.serie(column2))), cmp.horizontalList( cht.xyBarChart().setShowValues(true).setXValue(column2) .series(cht.xySerie(column3)), cht.xyLineChart().setShowValues(true).setValuePattern("#,##0.#").setXValue(column2) .series(cht.xySerie(column3)), cht.scatterChart().setShowValues(true).setXValue(column2) .series(cht.xySerie(column3))), cmp.horizontalList(cht.timeSeriesChart().setShowValues(true).setTimePeriod(column4) .series(cht.serie(column2), cht.serie(column3)).setTimePeriodType(TimePeriod.DAY), cht.differenceChart().setShowValues(true).setTimePeriod(column4) .series(cht.serie(column2), cht.serie(column3)) .setTimePeriodType(TimePeriod.DAY), cht.xyStepChart().setShowValues(true).setValuePattern("#,##0.#").setXValue(column2) .series(cht.xySerie(column3)), cht.waterfallBarChart().setShowValues(true).setValuePattern("#,##0.#") .setCategory(column1).series(cht.serie(column2)))); }
From source file:edu.usu.sdl.openstorefront.core.sort.BeanComparator.java
@Override public int compare(T o1, T o2) { T obj1 = o1;/*from w w w .j a v a 2 s . co m*/ T obj2 = o2; if (OpenStorefrontConstant.SORT_ASCENDING.equals(sortDirection)) { obj1 = o2; obj2 = o1; } if (obj1 != null && obj2 == null) { return 1; } else if (obj1 == null && obj2 != null) { return -1; } else if (obj1 != null && obj2 != null) { if (StringUtils.isNotBlank(sortField)) { try { Object o = obj1; Class<?> c = o.getClass(); Field f = c.getDeclaredField(sortField); f.setAccessible(true); if (f.get(o) instanceof Date) { int compare = 0; DateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH); if (BeanUtils.getProperty(obj1, sortField) != null && BeanUtils.getProperty(obj2, sortField) == null) { return 1; } else if (BeanUtils.getProperty(obj1, sortField) == null && BeanUtils.getProperty(obj2, sortField) != null) { return -1; } else if (BeanUtils.getProperty(obj1, sortField) != null && BeanUtils.getProperty(obj2, sortField) != null) { Date value1 = format.parse(BeanUtils.getProperty(obj1, sortField)); Date value2 = format.parse(BeanUtils.getProperty(obj2, sortField)); if (value1 != null && value2 == null) { return 1; } else if (value1 == null && value2 != null) { return -1; } else if (value1 != null && value2 != null) { compare = value1.compareTo(value2); } } return compare; } else { try { String value1 = BeanUtils.getProperty(obj1, sortField); String value2 = BeanUtils.getProperty(obj2, sortField); if (value1 != null && value2 == null) { return 1; } else if (value1 == null && value2 != null) { return -1; } else if (value1 != null && value2 != null) { if (StringUtils.isNotBlank(value1) && StringUtils.isNotBlank(value2) && StringUtils.isNumeric(value1) && StringUtils.isNumeric(value2)) { BigDecimal numValue1 = new BigDecimal(value1); BigDecimal numValue2 = new BigDecimal(value2); return numValue1.compareTo(numValue2); } else { return value1.toLowerCase().compareTo(value2.toLowerCase()); } } } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) { log.log(Level.FINER, MessageFormat.format("Sort field doesn''t exist: {0}", sortField)); } } } catch (ParseException | NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) { try { String value1 = BeanUtils.getProperty(obj1, sortField); String value2 = BeanUtils.getProperty(obj2, sortField); if (value1 != null && value2 == null) { return 1; } else if (value1 == null && value2 != null) { return -1; } else if (value1 != null && value2 != null) { if (StringUtils.isNotBlank(value1) && StringUtils.isNotBlank(value2) && StringUtils.isNumeric(value1) && StringUtils.isNumeric(value2)) { BigDecimal numValue1 = new BigDecimal(value1); BigDecimal numValue2 = new BigDecimal(value2); return numValue1.compareTo(numValue2); } else { return value1.toLowerCase().compareTo(value2.toLowerCase()); } } } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex2) { log.log(Level.FINER, MessageFormat.format("Sort field doesn''t exist: {0}", sortField)); } } } } return 0; }
From source file:com.joliciel.talismane.languageDetector.LanguageDetectorImpl.java
@Override public List<WeightedOutcome<Locale>> detectLanguages(String text) { MONITOR.startTask("detectLanguages"); try {/* ww w . jav a 2 s . co m*/ if (LOG.isTraceEnabled()) { LOG.trace("Testing text: " + text); } text = text.toLowerCase(Locale.ENGLISH); text = Normalizer.normalize(text, Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", ""); List<FeatureResult<?>> featureResults = new ArrayList<FeatureResult<?>>(); for (LanguageDetectorFeature<?> feature : features) { RuntimeEnvironment env = this.featureService.getRuntimeEnvironment(); FeatureResult<?> featureResult = feature.check(text, env); if (featureResult != null) featureResults.add(featureResult); } if (LOG.isTraceEnabled()) { for (FeatureResult<?> result : featureResults) { LOG.trace(result.toString()); } } List<Decision<LanguageOutcome>> decisions = this.decisionMaker.decide(featureResults); if (LOG.isTraceEnabled()) { for (Decision<LanguageOutcome> decision : decisions) { LOG.trace(decision.getCode() + ": " + decision.getProbability()); } } List<WeightedOutcome<Locale>> results = new ArrayList<WeightedOutcome<Locale>>(); for (Decision<LanguageOutcome> decision : decisions) { Locale locale = Locale.forLanguageTag(decision.getOutcome().getCode()); results.add(new WeightedOutcome<Locale>(locale, decision.getProbability())); } return results; } finally { MONITOR.endTask(); } }
From source file:com.shadwelldacunha.byteswipe.core.Utilities.java
public static void setLocalization() { C10N.configure(new C10NConfigBase() { @Override/* w w w.j av a2 s. c om*/ public void configure() { install(new DefaultC10NAnnotations()); setLocaleProvider(() -> Locale.ENGLISH); } }); }
From source file:jp.go.nict.langrid.management.web.view.page.language.component.form.validator.SameParallelLanguagePathValidator.java
public void validate(Form form) { List<String[]> list = parent.getNoValidateValueList(); List<String> tmp = new ArrayList<String>(); for (String[] inputs : list) { for (int i = 0; i < inputs.length; i++) { if (isWildcard(inputs[i])) { continue; }//from w ww.j a v a2s .co m if (tmp.contains(inputs[i])) { form.error(MessageManager.getMessage("SameParallelLanguagePathValidator", Locale.ENGLISH)); return; } tmp.add(inputs[i]); } } }
From source file:api.util.JsonUtil.java
public static Date asDate(Object val) { if (val == JSONObject.NULL) return null; if (val instanceof String) { String stringValue = (String) val; try {//w w w.j av a 2 s. co m // try ISO 8601 Calendar cal = DatatypeConverter.parseDateTime(stringValue); if (!iso8601Timezone.matcher(stringValue).matches()) { // timezone is absent from input string. Assume UTC cal.setTimeZone(TimeZone.getTimeZone("UTC")); } return cal.getTime(); } catch (IllegalArgumentException iae) { // fallback to RFC 2822 for (String format : new String[] { "EEE, dd MMM yyyy HH:mm:ss Z", "dd MMM yyyy HH:mm:ss Z", "EEE, dd MMM yyyy HH:mm Z", "dd MMM yyyy HH:mm Z", "EEE, dd MMM yyyy HH:mm:ss", "dd MMM yyyy HH:mm:ss", "EEE, dd MMM yyyy HH:mm", "dd MMM yyyy HH:mm" }) { SimpleDateFormat rfc2822Fmt = new SimpleDateFormat(format, Locale.ENGLISH); rfc2822Fmt.setTimeZone(TimeZone.getTimeZone("UTC")); try { return rfc2822Fmt.parse(stringValue); } catch (ParseException e) { } } } } else if (val instanceof Number) { return new Date(((Number) val).longValue() * 1000); } throw new IllegalArgumentException( "Value is expected to be a unix timestamp or a string in either ISO 8601 or RFC 2822 format: " + val); }
From source file:alfio.manager.EventNameManager.java
/** * Generates and returns a short name based on the given display name.<br> * The generated short name will be returned only if it was not already used.<br> * The input parameter will be clean from "evil" characters such as punctuation and accents * * 1) if the {@code displayName} is a one-word name, then no further calculation will be done and it will be returned as it is, to lower case * 2) the {@code displayName} will be split by word and transformed to lower case. If the total length is less than 15, then it will be joined using "-" and returned * 3) the first letter of each word will be taken, excluding numbers * 4) a random code will be returned/*from ww w.j a v a 2 s. co m*/ * * @param displayName * @return */ public String generateShortName(String displayName) { Validate.isTrue(StringUtils.isNotBlank(displayName)); String cleanDisplayName = StringUtils.stripAccents(StringUtils.normalizeSpace(displayName)) .toLowerCase(Locale.ENGLISH).replaceAll(FIND_EVIL_CHARACTERS, "-"); if (!StringUtils.containsWhitespace(cleanDisplayName) && isUnique(cleanDisplayName)) { return cleanDisplayName; } Optional<String> dashedName = getDashedName(cleanDisplayName); if (dashedName.isPresent()) { return dashedName.get(); } Optional<String> croppedName = getCroppedName(cleanDisplayName); if (croppedName.isPresent()) { return croppedName.get(); } return generateRandomName(); }
From source file:net.firejack.platform.core.exception.BusinessFunctionException.java
@Override public String getMessage() { String msg = super.getMessage(); if (StringUtils.isBlank(msg) && StringUtils.isNotBlank(getMsgKey())) { msg = MessageResolver.messageFormatting(getMsgKey(), Locale.ENGLISH, getMessageArguments()); }//from w ww . j a va2 s. c o m return msg; }
From source file:com.enonic.cms.domain.content.imports.ImportValueFormater.java
public static Date getDate(final AbstractSourceValue value, final String format) throws ImportException { String strValue = getStringValue(value); if (StringUtils.isEmpty(strValue)) { return null; }/*from w w w. j a v a 2s. c o m*/ String pattern = "yyyy-MM-dd"; try { if (StringUtils.isNotEmpty(format)) { pattern = format; } return new SimpleDateFormat(pattern, Locale.ENGLISH).parse(strValue); } catch (ParseException ex) { throw new ImportException( "Failed to parse date from value '" + strValue + "', using pattern: " + pattern, ex); } }
From source file:fr.treeptik.cloudunit.controller.SnapshotController.java
@RequestMapping(method = RequestMethod.POST) public JsonResponse create(@RequestBody JsonInput input) throws ServiceException, CheckException { CheckUtils.validateSyntaxInput(input.getTag(), this.messageSource.getMessage("check.snapshot.name", null, Locale.ENGLISH)); Application application;/*ww w.j a v a 2s .c o m*/ User user = null; try { user = authentificationUtils.getAuthentificatedUser(); application = applicationService.findByNameAndUser(user, input.getApplicationName()); // To be protected from WebUI uncontrolled requests (angularjs timeout) if (application.getUser().getStatus().equals(User.STATUS_NOT_ALLOWED)) { logger.info("Dispatch request"); return new HttpOk(); } authentificationUtils.forbidUser(user); // We must be sure there is no running action before starting new one this.authentificationUtils.canStartNewAction(null, application, locale); Status previousStatus = application.getStatus(); applicationService.setStatus(application, Status.PENDING); snapshotService.create(input.getApplicationName(), user, input.getTag(), input.getDescription(), previousStatus); applicationService.setStatus(application, previousStatus); } finally { authentificationUtils.allowUser(user); } return new HttpOk(); }