List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:I18NUtil.java
/** * Get the general local for the current thread, will revert to the default locale if none * specified for this thread./*from w ww . j a v a 2 s . c o m*/ * * @return the general locale */ public static Locale getLocale() { Locale locale = threadLocale.get(); if (locale == null) { // Get the default locale locale = Locale.getDefault(); } return locale; }
From source file:com.redhat.rhn.frontend.graphing.test.GraphGeneratorTest.java
/** * {@inheritDoc}//from ww w . ja v a 2s . c o m */ protected void setUp() throws Exception { super.setUp(); Context ctx = Context.getCurrentContext(); ctx.setTimezone(TimeZone.getDefault()); ctx.setLocale(Locale.getDefault()); }
From source file:com.fmguler.ven.LiquibaseUtil.java
/** * Undo all changes in the test database *//*from w w w.ja v a2 s .c o m*/ public static void rollbackDatabase(String tag) { try { Locale currLocale = Locale.getDefault(); Locale.setDefault(Locale.ENGLISH); Database database = DatabaseFactory.getInstance() .findCorrectDatabaseImplementation(getDataSource().getConnection()); Liquibase liquibase = new Liquibase("etc/test-db/test-db-changelog.xml", new FileSystemFileOpener(), database); liquibase.rollback(tag, ""); Locale.setDefault(currLocale); } catch (SQLException ex) { ex.printStackTrace(); } catch (JDBCException ex) { ex.printStackTrace(); } catch (LiquibaseException ex) { ex.printStackTrace(); } }
From source file:cn.newcapec.framework.core.utils.dataUtils.DateMorpherEx.java
public DateMorpherEx(String[] formats, Date defaultValue) { this(formats, defaultValue, Locale.getDefault(), false); }
From source file:org.vaadin.spring.i18n.I18NTest.java
@Test public void get_noCurrentUIAndMessageIsResolved_messageIsReturned() { final Locale locale = Locale.getDefault(); when(applicationContext.getMessage("myCode", new Object[] { "myArg" }, locale)).thenReturn("myMessage"); assertNull(UI.getCurrent());/*from w w w. j a va 2 s .c om*/ assertEquals("myMessage", i18n.get("myCode", "myArg")); }
From source file:com.mindquarry.desktop.I18N.java
protected static Map<String, String> initTranslationMap(String fileBase, String fileSuffix) { try {/*from ww w . j a va 2s.c om*/ SAXParserFactory parserFactory = SAXParserFactory.newInstance(); parserFactory.setValidating(false); SAXParser parser = parserFactory.newSAXParser(); XMLReader reader = parser.getXMLReader(); TranslationMessageParser translationParser = new TranslationMessageParser(); reader.setContentHandler(translationParser); reader.setErrorHandler(translationParser); // TODO: use "xx_YY" if available, use "xx" otherwise: String transFile = fileBase + Locale.getDefault().getLanguage() + fileSuffix; InputStream is = I18N.class.getResourceAsStream(transFile); if (is == null) { // no translation available for this language log.debug("No translation file available for language: " + Locale.getDefault().getLanguage()); return new HashMap<String, String>(); } log.debug("Loading translation file " + transFile + " from JAR"); reader.parse(new InputSource(is)); return translationParser.getMap(); } catch (Exception e) { throw new RuntimeException(e.toString(), e); } }
From source file:com.flipkart.polyguice.config.ApacheCommonsConfigProvider.java
public ApacheCommonsConfigProvider location(String loc) { try {/*from w w w . j a v a2 s .c o m*/ if (loc.toLowerCase(Locale.getDefault()).endsWith(".properties")) { PropertiesConfiguration config = new PropertiesConfiguration(new File(loc)); rootConfig.addConfiguration(config); LOGGER.debug("properties configuration from {}", loc); } else if (loc.toLowerCase(Locale.getDefault()).endsWith(".xml")) { XMLConfiguration config = new XMLConfiguration(new File(loc)); rootConfig.addConfiguration(config); LOGGER.debug("xml configuration from {}", loc); } else if (loc.toLowerCase(Locale.getDefault()).endsWith(".json")) { JsonConfiguration config = new JsonConfiguration(new File(loc)); rootConfig.addConfiguration(config); LOGGER.debug("json configuration from {}", loc); } else if (loc.toLowerCase(Locale.getDefault()).endsWith(".yml")) { YamlConfiguration config = new YamlConfiguration(loc); rootConfig.addConfiguration(config); LOGGER.debug("yaml configuration from {}", loc); } else if (loc.toLowerCase(Locale.getDefault()).endsWith(".yaml")) { YamlConfiguration config = new YamlConfiguration(loc); rootConfig.addConfiguration(config); LOGGER.debug("yaml configuration from {}", loc); } } catch (Exception exep) { LOGGER.error("unable to load configuration from " + loc.toString(), exep); } return this; }
From source file:com.mylaensys.dhtmlx.adapter.test.TestForm.java
@Test public void defaultFormAdapter() throws Exception { DefaultFormAdapter adapter = new DefaultFormAdapter(object); String xml1 = adapter.serialize(Locale.getDefault()); System.out.print(xml1);/*from w w w . j a va2 s .c o m*/ System.out.println(""); DefaultFormAdapter mobileAdapter = new DefaultFormAdapter(object, new MobileFormInterceptor()); String xml2 = mobileAdapter.serialize(Locale.getDefault()); System.out.print(xml2); System.out.println(""); }
From source file:com.healthcit.analytics.dao.impl.JdbcReportTemplateDAO.java
@Override public ReportTemplate getReportTemplateById(Long id) { String sql = messageSource.getMessage(Constants.GET_REPORT_BY_ID_SQL, null, Locale.getDefault()); List<ReportTemplate> results = jdbcTemplate.query(sql, new Object[] { id }, new ReportTemplateRowMapper()); return (results.isEmpty() ? null : results.get(0)); }
From source file:com.googlecode.jtiger.modules.ecside.util.ExtremeUtils.java
public static String formatDate(String parse, String format, Object value) { return formatDate(parse, format, value, Locale.getDefault()); }