List of usage examples for java.util Locale Locale
public Locale(String language)
From source file:jatran.stub.AStrutsAction.java
/** * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are proceeding * @param response The HTTP response we are creating * @return an ActionForward instance describing where and how * control should be forwarded, or null if response * has already been completed/*from w w w. j a v a 2s. c om*/ */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { HttpSession session = request.getSession(); TotalsHourlyForm totalsHourlyForm = (TotalsHourlyForm) form; Locale locale = (Locale) session.getAttribute(Globals.LOCALE_KEY); if (locale == null) { locale = new Locale("en"); } Calendar calendar = Calendar.getInstance(); boolean dateIsNow = true; if (!GenericValidator.isBlankOrNull(totalsHourlyForm.getDate())) { try { Date date = DateUtil.parseDate(totalsHourlyForm.getDate(), locale); dateIsNow = false; calendar.setTime(date); } catch (ParseException e) { } } if (dateIsNow) { totalsHourlyForm.setDate(DateUtil.formatDate(calendar.getTime(), locale)); } StatisticsManager statisticsManager = (StatisticsManager) getBean(Constants.STATISTICS_MANAGER_BEAN); Integer day = new Integer(calendar.get(Calendar.DAY_OF_MONTH)); Integer month = new Integer(calendar.get(Calendar.MONTH) + 1); Integer year = new Integer(calendar.get(Calendar.YEAR)); List hours = statisticsManager.getTotalsHourly(year, month, day); int maxTotal = 1; int maxUnique = 1; for (Iterator i = hours.iterator(); i.hasNext();) { Object[] hourDescr = (Object[]) i.next(); Integer total = (Integer) hourDescr[1]; Integer unique = (Integer) hourDescr[2]; if (total.intValue() > maxTotal) { maxTotal = total.intValue(); } if (unique.intValue() > maxUnique) { maxUnique = unique.intValue(); } } request.setAttribute("hours", hours); request.setAttribute("maxTotal", new Integer(maxTotal)); request.setAttribute("maxUnique", new Integer(maxUnique)); Date date = calendar.getTime(); request.setAttribute("date", date); return mapping.findForward("showTotalsHourly"); }
From source file:com.inkubator.hrm.web.payroll.PayTempOvertimeFormController.java
public void handingFileUpload(FileUploadEvent fileUploadEvent) { Map<String, String> results = uploadFilesUtil.checkUploadFileSizeLimit(fileUploadEvent.getFile()); if (StringUtils.equals(results.get("result"), "true")) { file = fileUploadEvent.getFile(); fileName = file.getFileName();/* www . j a va 2s . c o m*/ } else { ResourceBundle messages = ResourceBundle.getBundle("Messages", new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString())); String errorMsg = messages.getString("global.file_size_should_not_bigger_than") + " " + results.get("sizeMax"); MessagesResourceUtil.setMessagesFromException(FacesMessage.SEVERITY_ERROR, "global.error", errorMsg, FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()); } }
From source file:de.ingrid.portal.interfaces.wms.WMSInterfaceTest.java
public void testGetWMSSearchURL() { String myUrl = wmsInterface.getWMSSearchURL("session0815", true, new Locale("de")); if (config.getProperty("display_search_url").toString().indexOf("?") > 0) { assertEquals(config.getProperty("display_search_url") + "&PHPSESSID=session0815&lang=de", myUrl); } else {/*w w w.ja v a 2 s . c o m*/ assertEquals(config.getProperty("display_search_url") + "?PHPSESSID=session0815&lang=de", myUrl); } }
From source file:at.alladin.rmbt.controlServer.OpenTestQoSResource.java
@Post("json") public String request(final String entity) { addAllowOrigin();/*www . jav a2s.c o m*/ final ErrorList errorList = new ErrorList(); final JSONObject answer = new JSONObject(); String answerString; System.out.println(MessageFormat.format(labels.getString("NEW_QOS_RESULT_REQUEST"), getIP())); try { String lang = null; String openUUID = getRequest().getAttributes().get("open_test_uuid").toString(); if (getRequest().getAttributes().containsKey("lang")) { lang = getRequest().getAttributes().get("lang").toString(); } else { List<Preference<Language>> languageList = getRequest().getClientInfo().getAcceptedLanguages(); if (languageList != null && languageList.size() > 0) { lang = languageList.get(0).getMetadata().getName(); } } // Load Language Files for Client final List<String> langs = Arrays.asList(settings.getString("RMBT_SUPPORTED_LANGUAGES").split(",\\s*")); if (langs.contains(lang)) { labels = (PropertyResourceBundle) ResourceBundle.getBundle("at.alladin.rmbt.res.SystemMessages", new Locale(lang)); } else { lang = settings.getString("RMBT_DEFAULT_LANGUAGE"); } errorList.setLanguage(lang); if (conn != null) { QoSUtil.evaluate(settings, conn, new TestUuid(openUUID, UuidType.OPEN_TEST_UUID), answer, lang, errorList); } else { errorList.addError("ERROR_DB_CONNECTION"); } } catch (final JSONException e) { errorList.addError("ERROR_REQUEST_JSON"); e.printStackTrace(); } catch (SQLException e) { errorList.addError("ERROR_DB_CONNECTION"); e.printStackTrace(); } catch (HstoreParseException e) { errorList.addErrorString(e.getMessage()); e.printStackTrace(); } catch (IllegalArgumentException e) { errorList.addError("ERROR_REQUEST_JSON"); e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedOperationException e) { errorList.addError("ERROR_REQUEST_QOS_RESOURCE_DETAIL_NO_UUID"); } try { answer.putOpt("error", errorList.getList()); } catch (final JSONException e) { System.out.println("Error saving ErrorList: " + e.toString()); } answerString = answer.toString(); return answerString; }
From source file:com.erudika.para.i18n.LanguageUtils.java
/** * Default constructor./*from www .j a va2s. co m*/ * @param search a core search instance * @param dao a core persistence instance */ @Inject public LanguageUtils(Search search, DAO dao) { this.search = search; this.dao = dao; for (Object loc : LocaleUtils.availableLocaleList()) { Locale locale = new Locale(((Locale) loc).getLanguage()); String locstr = locale.getLanguage(); if (!StringUtils.isBlank(locstr)) { allLocales.put(locstr, locale); progressMap.put(locstr, 0); } } }
From source file:com.exxonmobile.ace.hybris.core.event.AbstractOrderEventListener.java
protected void setSessionLocaleForOrder(final OrderModel order) { if (order.getLocale() != null) { getI18NService().setCurrentLocale(new Locale(order.getLocale())); }// w w w.j a v a 2 s . c o m }
From source file:com.netsteadfast.greenstep.action.LoginAction.java
private void setLocaleLanguage() { if (StringUtils.isBlank(this.lang)) { this.lang = LocaleLanguageUtils.getDefault(); }//from w w w . j a v a 2 s .c om if (LocaleLanguageUtils.getMap().get(this.lang) == null) { this.lang = LocaleLanguageUtils.getDefault(); } Locale locale = new Locale(this.lang); ActionContext.getContext().setLocale(locale); }
From source file:jp.terasoluna.fw.beans.jxpath.BeanPointerFactoryExTest.java
/** * testCreateNodePointerQname01() <br> * <br>/*from ww w .j av a 2 s . c o m*/ * () <br> * A <br> * <br> * () name:not null<br> * () bean:new Object()<br> * () locale:Locale("ja")<br> * <br> * () NodePointer:new BeanPointerEX {<br> * locale=?locale<br> * name=?name<br> * bean=?bean<br> * }<br> * <br> * ??? <br> * @throws Exception ????? */ @Test public void testCreateNodePointerQname01() throws Exception { // ?? BeanPointerFactoryEx factory = new BeanPointerFactoryEx(); QName qName = new QName("name"); Object bean = new Object(); Locale locale = new Locale("ja"); // NodePointer result = factory.createNodePointer(qName, bean, locale); // assertSame(BeanPointerEx.class, result.getClass()); assertSame(locale, result.getLocale()); assertSame(qName, result.getName()); assertSame(bean, ReflectionTestUtils.getField(result, "bean")); }
From source file:gr.abiss.calipso.plugins.state.ep.ExampleEp3BusinessLogicPlugin.java
/** * @see gr.abiss.calipso.plugins.state.AbstractStatePlugin#execute(gr.abiss.calipso.CalipsoService, gr.abiss.calipso.domain.History) *///from w w w. ja va2 s. c om @Override public Serializable executePostStateChange(CalipsoService calipsoService, History history) { // get the item the history belongs to Item item = history.getParent(); AssetType assetType = calipsoService.loadAssetType(5); int numberOfEps = item.getCusDbl01().intValue(); List<String> comments = new ArrayList<String>(numberOfEps); Date now = history.getTimeStamp(); Locale userLocale = new Locale(history.getLoggedBy().getLocale()); for (int i = 0; i < numberOfEps; i++) { Asset asset = new Asset(); asset.setInventoryCode(item.getUniqueRefId() + i); asset.setAssetType(assetType); asset.setSupportStartDate(now); // copy information from item initFromHistoryItem(calipsoService, item, asset, assetType); // add to asset and history item.addAsset(asset); // save the asset calipsoService.storeAsset(asset); comments.add(ItemUtils.fmt("item_view.automatically.created.asset", new Object[] { assetType.getName(), asset.getInventoryCode() }, calipsoService.getMessageSource(), userLocale)); } StringBuffer commentsBuf = new StringBuffer("<ul>"); if (CollectionUtils.isNotEmpty(comments)) { for (String comment : comments) { commentsBuf.append("<li>").append(XmlUtils.stripTags(comment)).append("</li>"); } } commentsBuf.append("</ul>"); // update html and plain text comment String htmlSuffix = commentsBuf.toString(); history.setHtmlComment(htmlSuffix); history.setComment(history.getComment() + XmlUtils.stripTags(htmlSuffix)); calipsoService.updateItem(item, history.getLoggedBy(), false); //calipsoService.updateHistory(history); return null; }
From source file:org.cybercat.automation.core.PageFactoryImpl.java
/** * Initializes and returns page class instance * /*from w ww . j a v a2s . co m*/ * @param page * - page class * @throws PageObjectException */ protected <T extends AbstractPageObject> T initPage(T page) throws PageObjectException { // get locators Locale locale; try { locale = new Locale(AutomationMain.getProperty("language")); } catch (AutomationFrameworkException e) { throw new PageObjectException("Main factory initialization exception.", e); } try { Browser browser = Browser.getCurrentBrowser(); LOG.info("Current URL: " + getCurrentUrl()); if (StringUtils.isNotBlank(page.getPageUrl()) && !browser.getCurrentUrl().contains(page.getPageUrl())) { LOG.error("Navigate to URL: " + page.getPageUrl()); throw new PageObjectException("Page validation exception. Expected page URL is " + page.getPageUrl() + " URL in fact " + getCurrentUrl()); } page.setPageFactory(this); page.init(browser, locale); LOG.info(page.getClass().getName() + " page created."); } catch (Exception e) { throw new PageObjectException("Unable initialize " + page.getClass().getName() + " page by URL: " + page.getPageUrl() + "\n" + e.getMessage(), e); } return page; }