List of usage examples for java.util Locale getDefault
public static Locale getDefault()
From source file:com.sunchenbin.store.feilong.core.text.DateFormatUtil.java
/** * format??./* www . j a v a 2 s . c om*/ * * <p> * {@link #format(Date, String, Locale)},locale {@link Locale#getDefault()}. * </p> * * @param date * the date * @param pattern * the pattern * @return the string * @see #format(Date, String, Locale) */ public static String format(Date date, String pattern) { return format(date, pattern, Locale.getDefault()); }
From source file:com.tracer.util.CommonConverter.java
/** * Creates new instance of CommonConverter with default locale */ public CommonConverter() { this(Locale.getDefault()); }
From source file:Main.java
/** * Convert a string based locale into a Locale Object * <br>//w w w . ja va2 s . c o m * <br>Strings are formatted: * <br> * <br>language_contry_variant * **/ public static Locale getLocaleFromString(String localeString) { if (localeString == null) { return null; } if (localeString.toLowerCase().equals("default")) { return Locale.getDefault(); } int languageIndex = localeString.indexOf('_'); if (languageIndex == -1) { return null; } int countryIndex = localeString.indexOf('_', languageIndex + 1); String country = null; if (countryIndex == -1) { if (localeString.length() > languageIndex) { country = localeString.substring(languageIndex + 1, localeString.length()); } else { return null; } } int variantIndex = -1; if (countryIndex != -1) { countryIndex = localeString.indexOf('_', countryIndex + 1); } String language = localeString.substring(0, languageIndex); String variant = null; if (variantIndex != -1) { variant = localeString.substring(variantIndex + 1, localeString.length()); } if (variant != null) { return new Locale(language, country, variant); } else { return new Locale(language, country); } }
From source file:com.vmware.bdd.exception.BddException.java
protected static String getErrorMessage(final String errorId, Object... args) { String msg = messageSource.getMessage(errorId, args, Locale.getDefault()); return msg;//from ww w . j a v a2 s .c om }
From source file:com.assemblade.utils.localisation.Localiser.java
private Localiser() { localisedStrings = new Properties(); Locale current = Locale.getDefault(); String language = current.getLanguage(); String propertyFile = language + ".properties"; InputStream is = Localiser.class.getClassLoader().getResourceAsStream(propertyFile); if (is != null) { propertyFile = "en.properties"; is = Localiser.class.getClassLoader().getResourceAsStream(propertyFile); }/*from ww w . j ava2 s . co m*/ if (is != null) { try { localisedStrings.load(is); } catch (IOException e) { log.error("Failed to load localised properties from resource: " + propertyFile, e); } } else { log.error("Could not find default localisation property file: " + propertyFile); } }
From source file:at.favre.tools.dconvert.ui.CLIInterpreter.java
public static Arguments parse(String[] args) { ResourceBundle strings = ResourceBundle.getBundle("bundles.strings", Locale.getDefault()); Options options = setupOptions(strings); CommandLineParser parser = new DefaultParser(); Arguments.Builder builder;//from w ww .j av a2 s. c om try { CommandLine commandLine = parser.parse(options, args); if (commandLine.hasOption("gui")) { return Arguments.START_GUI; } if (commandLine.hasOption("h") || commandLine.hasOption("help")) { printHelp(options); return null; } if (commandLine.hasOption("v") || commandLine.hasOption("version")) { System.out.println("Version: " + CLIInterpreter.class.getPackage().getImplementationVersion()); return null; } String scaleRawParam = commandLine.getOptionValue(SCALE_ARG).toLowerCase(); boolean dp = false; if (scaleRawParam.contains("dp")) { dp = true; scaleRawParam = scaleRawParam.replace("dp", "").trim(); } builder = new Arguments.Builder(new File(commandLine.getOptionValue(SOURCE_ARG)), Float.parseFloat(scaleRawParam)); if (dp && commandLine.hasOption(SCALE_IS_HEIGHT_DP_ARG)) { builder.scaleMode(EScaleMode.DP_HEIGHT); } else if (dp && !commandLine.hasOption(SCALE_IS_HEIGHT_DP_ARG)) { builder.scaleMode(EScaleMode.DP_WIDTH); } else { builder.scaleMode(EScaleMode.FACTOR); } if (commandLine.hasOption(DST_ARG)) { builder.dstFolder(new File(commandLine.getOptionValue(DST_ARG))); } float compressionQuality = Arguments.DEFAULT_COMPRESSION_QUALITY; if (commandLine.hasOption(COMPRESSION_QUALITY_ARG)) { compressionQuality = Float.valueOf(commandLine.getOptionValue(COMPRESSION_QUALITY_ARG)); } if (commandLine.hasOption(OUT_COMPRESSION_ARG)) { switch (commandLine.getOptionValue(OUT_COMPRESSION_ARG)) { case "strict": builder.compression(EOutputCompressionMode.SAME_AS_INPUT_STRICT); break; case "png": builder.compression(EOutputCompressionMode.AS_PNG); break; case "jpg": builder.compression(EOutputCompressionMode.AS_JPG, compressionQuality); break; case "gif": builder.compression(EOutputCompressionMode.AS_GIF); break; case "bmp": builder.compression(EOutputCompressionMode.AS_BMP); break; case "png+jpg": builder.compression(EOutputCompressionMode.AS_JPG_AND_PNG, compressionQuality); break; default: System.err.println( "unknown compression type: " + commandLine.getOptionValue(OUT_COMPRESSION_ARG)); } } Set<EPlatform> platformSet = new HashSet<>(EPlatform.values().length); if (commandLine.hasOption(PLATFORM_ARG)) { switch (commandLine.getOptionValue(PLATFORM_ARG)) { case "all": platformSet = EPlatform.getAll(); break; case "android": platformSet.add(EPlatform.ANDROID); break; case "ios": platformSet.add(EPlatform.IOS); break; case "win": platformSet.add(EPlatform.WINDOWS); break; case "web": platformSet.add(EPlatform.WEB); break; default: System.err.println("unknown mode: " + commandLine.getOptionValue(PLATFORM_ARG)); } builder.platform(platformSet); } if (commandLine.hasOption(UPSCALING_ALGO_ARG)) { builder.upScaleAlgorithm( EScalingAlgorithm.getByName(commandLine.getOptionValue(UPSCALING_ALGO_ARG))); } if (commandLine.hasOption(DOWNSCALING_ALGO_ARG)) { builder.upScaleAlgorithm( EScalingAlgorithm.getByName(commandLine.getOptionValue(DOWNSCALING_ALGO_ARG))); } if (commandLine.hasOption(ROUNDING_MODE_ARG)) { switch (commandLine.getOptionValue(ROUNDING_MODE_ARG)) { case "round": builder.scaleRoundingStragy(RoundingHandler.Strategy.ROUND_HALF_UP); break; case "ceil": builder.scaleRoundingStragy(RoundingHandler.Strategy.CEIL); break; case "floor": builder.scaleRoundingStragy(RoundingHandler.Strategy.FLOOR); break; default: System.err.println("unknown mode: " + commandLine.getOptionValue(ROUNDING_MODE_ARG)); } } if (commandLine.hasOption(THREADS_ARG)) { builder.threadCount(Integer.valueOf(commandLine.getOptionValue(THREADS_ARG))); } builder.skipUpscaling(commandLine.hasOption("skipUpscaling")); builder.skipExistingFiles(commandLine.hasOption(SKIP_EXISTING_ARG)); builder.includeAndroidLdpiTvdpi(commandLine.hasOption("androidIncludeLdpiTvdpi")); builder.verboseLog(commandLine.hasOption(VERBOSE_ARG)); builder.haltOnError(commandLine.hasOption("haltOnError")); builder.createMipMapInsteadOfDrawableDir(commandLine.hasOption("androidMipmapInsteadOfDrawable")); builder.antiAliasing(commandLine.hasOption("antiAliasing")); builder.enablePngCrush(commandLine.hasOption("postProcessorPngCrush")); builder.postConvertWebp(commandLine.hasOption("postProcessorWebp")); builder.dryRun(commandLine.hasOption("dryRun")); builder.enableMozJpeg(commandLine.hasOption("postProcessorMozJpeg")); builder.keepUnoptimizedFilesPostProcessor(commandLine.hasOption("keepOriginalPostProcessedFiles")); builder.iosCreateImagesetFolders(commandLine.hasOption("iosCreateImagesetFolders")); builder.clearDirBeforeConvert(commandLine.hasOption("clean")); return builder.build(); } catch (Exception e) { System.err.println("Could not parse args: " + e.getMessage()); } return null; }
From source file:net.granoeste.validator.DateValidator.java
public DateValidator(final String errorMessage, final String datePattern, final boolean strict) { super(errorMessage); mValidator = org.apache.commons.validator.DateValidator.getInstance(); mLocale = Locale.getDefault(); mDatePattern = datePattern;/* www . ja v a2 s. c o m*/ mStrict = strict; }
From source file:cn.newcapec.framework.core.utils.dataUtils.DateMorpherEx.java
public DateMorpherEx(String[] formats) { this(formats, Locale.getDefault(), false); }
From source file:com.jmstoolkit.logging.JTKLogListenerImpl.java
/** * * @param arg0 the JMS Message//from w w w. j a v a 2 s. c om */ @Override public final void onMessage(final Message arg0) { try { if (arg0 instanceof TextMessage) { System.out.printf(Locale.getDefault(), "Logger service got the message:\n %s \n", ((TextMessage) arg0).getText()); } else { System.out.printf(Locale.getDefault(), "Logger service got the message. JMS ID: %s\n", arg0.getJMSMessageID()); } } catch (JMSException e) { System.err.printf(Locale.getDefault(), "JMS Failure: \n %s\n", e); } }
From source file:ResourceManager.java
/** * @param packageName package name, used for * <code>Resources.properties</code> file look-up * @param messageKey message key//from www . j a va 2 s. c om * @return message for {@link Locale#getDefault() default locale} */ public static String getMessage(final String packageName, final String messageKey) { return getMessage(packageName, messageKey, Locale.getDefault(), null); }