javax.servlet.http.HttpServletRequestWrapper#java.util.Locale源码实例Demo

下面列出了javax.servlet.http.HttpServletRequestWrapper#java.util.Locale 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Time4A   文件: EastAsianST.java
@Override
public String getDisplayName(Locale locale) {
    String lang = locale.getLanguage();

    if (lang.equals("zh")) {
        return locale.getCountry().equals("TW") ? "節氣" : "节气";
    } else if (lang.equals("ko")) {
        return "절기";
    } else if (lang.equals("vi")) {
        return "tiết khí";
    } else if (lang.equals("ja")) {
        return "節気";
    } else if (lang.isEmpty()) {
        return "jieqi";
    } else {
        return "jiéqì"; // pinyin
    }
}
 
源代码2 项目: openjdk-8   文件: TimeZoneNameUtility.java
private static String examineAliases(TimeZoneNameProvider tznp, Locale locale,
                                     String requestID, String tzid, int style,
                                     Map<String, String> aliases) {
    if (aliases.containsValue(tzid)) {
        for (Map.Entry<String, String> entry : aliases.entrySet()) {
            if (entry.getValue().equals(tzid)) {
                String alias = entry.getKey();
                String name = getName(tznp, locale, requestID, style, alias);
                if (name != null) {
                    return name;
                }
                name = examineAliases(tznp, locale, requestID, alias, style, aliases);
                if (name != null) {
                    return name;
                }
            }
        }
    }
    return null;
}
 
源代码3 项目: jdk8u-jdk   文件: ZoneName.java
public static String toZid(String zid, Locale locale) {
    String mzone = zidToMzone.get(zid);
    if (mzone == null && aliases.containsKey(zid)) {
        zid = aliases.get(zid);
        mzone = zidToMzone.get(zid);
    }
    if (mzone != null) {
        Map<String, String> map = mzoneToZidL.get(mzone);
        if (map != null && map.containsKey(locale.getCountry())) {
            zid = map.get(locale.getCountry());
        } else {
            zid = mzoneToZid.get(mzone);
        }
    }
    return toZid(zid);
}
 
@Override
public List<Route> routes() {
    return ImmutableList
        .of(
            // start AD job
            new Route(
                RestRequest.Method.POST,
                String.format(Locale.ROOT, "%s/{%s}/%s", AnomalyDetectorPlugin.AD_BASE_DETECTORS_URI, DETECTOR_ID, START_JOB)
            ),
            // stop AD job
            new Route(
                RestRequest.Method.POST,
                String.format(Locale.ROOT, "%s/{%s}/%s", AnomalyDetectorPlugin.AD_BASE_DETECTORS_URI, DETECTOR_ID, STOP_JOB)
            )
        );
}
 
public static void createServerAddOperations(final List<ModelNode> addOps, final PathAddress protocolAddress, final ModelNode protocol) {
    addOps.add(createProtocolAddOperation(protocolAddress, protocol));

    final SyslogAuditLogHandler.Transport transport = SyslogAuditLogHandler.Transport.valueOf(protocolAddress.getLastElement().getValue().toUpperCase(Locale.ENGLISH));
    if (transport == SyslogAuditLogHandler.Transport.TLS){
        if (protocol.hasDefined(AUTHENTICATION)){
            final ModelNode auth = protocol.get(AUTHENTICATION);
            if (auth.hasDefined(TRUSTSTORE)){
                addOps.add(createKeystoreAddOperation(protocolAddress.append(AUTHENTICATION, TRUSTSTORE), protocol.get(AUTHENTICATION, TRUSTSTORE)));
            }
            if (auth.hasDefined(CLIENT_CERT_STORE)){
                addOps.add(createKeystoreAddOperation(protocolAddress.append(AUTHENTICATION, CLIENT_CERT_STORE), protocol.get(AUTHENTICATION, CLIENT_CERT_STORE)));
            }
        }
    }
}
 
源代码6 项目: tomee   文件: MathRuntimeException.java
/**
 * Constructs a new <code>NullPointerException</code> with specified formatted detail message.
 * Message formatting is delegated to {@link MessageFormat}.
 *
 * @param pattern   format specifier
 * @param arguments format arguments
 * @return built exception
 */
public static NullPointerException createNullPointerException(final String pattern,
                                                              final Object... arguments) {
    return new NullPointerException() {

        /** Serializable version identifier. */
        private static final long serialVersionUID = -3075660477939965216L;

        /** {@inheritDoc} */
        @Override
        public String getMessage() {
            return buildMessage(Locale.US, pattern, arguments);
        }

        /** {@inheritDoc} */
        @Override
        public String getLocalizedMessage() {
            return buildMessage(Locale.getDefault(), pattern, arguments);
        }

    };
}
 
源代码7 项目: OpenDA   文件: Time.java
/**
 * Represent the time object as string
 *
 * @return string representation of time
 * @param time Time to be presented as string
 */
public static String asDateString(ITime time) {
	String result;
	if (time.isStamp()) {
		result = timeStampToDate(time.getMJD()).toString();
	} else {
		if ((time.getEndTime().getMJD() - time.getBeginTime().getMJD()) < getTimePrecision()) {
			result = timeStampToDate(0.5 * (time.getBeginTime().getMJD()
					+ time.getEndTime().getMJD())).toString();
		} else {
			Locale locale = new Locale("EN");
			String stepFormat = "%6.6f";
			result = timeStampToDate(time.getBeginTime().getMJD()).toString() + " - step=" +
					String.format(locale, stepFormat, time.getStepMJD()) + " - " +
					timeStampToDate(time.getEndTime().getMJD());
		}
	}
	return result;
}
 
源代码8 项目: lua-for-android   文件: RichDiagnosticFormatter.java
@Override
public String visitMethodSymbol(MethodSymbol s, Locale locale) {
    String ownerName = visit(s.owner, locale);
    if (s.isStaticOrInstanceInit()) {
       return ownerName;
    } else {
        String ms = (s.name == s.name.table.names.init)
            ? ownerName
            : s.name.toString();
        if (s.type != null) {
            if (s.type.hasTag(FORALL)) {
                ms = "<" + visitTypes(s.type.getTypeArguments(), locale) + ">" + ms;
            }
            ms += "(" + printMethodArgs(
                    s.type.getParameterTypes(),
                    (s.flags() & VARARGS) != 0,
                    locale) + ")";
        }
        return ms;
    }
}
 
源代码9 项目: AOSP-Kayboard-7.1.2   文件: LocaleUtils.java
/**
 * Execute {@link #job(Resources)} method in specified system locale exclusively.
 *
 * @param res       the resources to use. Pass current resources.
 * @param newLocale the locale to change to
 * @return the value returned from {@link #job(Resources)}.
 */
public T runInLocale(final Resources res, final Locale newLocale) {
    synchronized (sLockForRunInLocale) {
        final Configuration conf = res.getConfiguration();
        final Locale oldLocale = conf.locale;
        try {
            if (newLocale != null && !newLocale.equals(oldLocale)) {
                conf.locale = newLocale;
                res.updateConfiguration(conf, null);
            }
            return job(res);
        } finally {
            if (newLocale != null && !newLocale.equals(oldLocale)) {
                conf.locale = oldLocale;
                res.updateConfiguration(conf, null);
            }
        }
    }
}
 
源代码10 项目: jdk8u-dev-jdk   文件: Test6524757.java
public static void main(String[] args) {
    Locale reservedLocale = Locale.getDefault();
    try {
        // it affects Swing because it is not initialized
        Locale.setDefault(Locale.KOREAN);
        validate(KOREAN, create());

        // it does not affect Swing because it is initialized
        Locale.setDefault(Locale.CANADA);
        validate(KOREAN, create());

        // it definitely should affect Swing
        JComponent.setDefaultLocale(Locale.FRENCH);
        validate(FRENCH, create());
    } finally {
        // restore the reserved locale
        Locale.setDefault(reservedLocale);
    }
}
 
源代码11 项目: Java8CN   文件: FileNameExtensionFilter.java
/**
 * Creates a {@code FileNameExtensionFilter} with the specified
 * description and file name extensions. The returned {@code
 * FileNameExtensionFilter} will accept all directories and any
 * file with a file name extension contained in {@code extensions}.
 *
 * @param description textual description for the filter, may be
 *                    {@code null}
 * @param extensions the accepted file name extensions
 * @throws IllegalArgumentException if extensions is {@code null}, empty,
 *         contains {@code null}, or contains an empty string
 * @see #accept
 */
public FileNameExtensionFilter(String description, String... extensions) {
    if (extensions == null || extensions.length == 0) {
        throw new IllegalArgumentException(
                "Extensions must be non-null and not empty");
    }
    this.description = description;
    this.extensions = new String[extensions.length];
    this.lowerCaseExtensions = new String[extensions.length];
    for (int i = 0; i < extensions.length; i++) {
        if (extensions[i] == null || extensions[i].length() == 0) {
            throw new IllegalArgumentException(
                "Each extension must be non-null and not empty");
        }
        this.extensions[i] = extensions[i];
        lowerCaseExtensions[i] = extensions[i].toLowerCase(Locale.ENGLISH);
    }
}
 
@Override
protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {
       Subject subject = getSubject(request, response);

       // Check if POST only logout is enabled
       if (isPostOnlyLogout()) {
           // check if the current request's method is a POST, if not redirect
           if (!WebUtils.toHttp(request).getMethod().toUpperCase(Locale.ENGLISH).equals("POST")) {
              return onLogoutRequestNotAPost(request, response);
           }
       }

       String redirectUrl = getRedirectUrl(request, response, subject);
       //try/catch added for SHIRO-298:
       try {
       	String account = (String) subject.getPrincipal();
           subject.logout();
           this.authListenerManager.onLogout(request, account);
       } catch (SessionException ise) {
       	LOGGER.debug("Encountered session exception during logout.  This can generally safely be ignored.", ise);
       }
       issueRedirect(request, response, redirectUrl);
       return false;
}
 
源代码13 项目: TelePlus-Android   文件: DrawerLayoutAdapter.java
public void swapAccountPosition(int currentAdapterPosition, int targetAdapterPosition)
{
    int currentIndex = currentAdapterPosition - 2;
    int targetIndex = targetAdapterPosition - 2;
    int currentElement = accountNumbers.get(currentIndex);
    int targetElement = accountNumbers.get(targetIndex);
    accountNumbers.set(targetIndex, currentElement);
    accountNumbers.set(currentIndex, targetElement);
    MessagesController.getGlobalMainSettings().edit().
            putLong(String.format(Locale.US, "account_pos_%d", currentElement), targetIndex).
            putLong(String.format(Locale.US, "account_pos_%d", targetElement), currentIndex)
            .apply();
    notifyItemMoved(currentAdapterPosition, targetAdapterPosition);
}
 
源代码14 项目: tomee   文件: LocalFileHandler.java
@Override
public String format(final LogRecord record) {
    final Date date = this.date.get();
    date.setTime(record.getMillis());

    String source;
    final String sourceClassName = record.getSourceClassName();
    final String sourceMethodName = record.getSourceMethodName();
    if (sourceClassName != null) {
        source = sourceClassName;
        if (sourceMethodName != null) {
            source += " " + sourceMethodName;
        }
    } else {
        source = record.getLoggerName();
    }

    final String message = formatMessage(record);

    String throwable = "";
    final Throwable thrown = record.getThrown();
    if (thrown != null) {
        final StringWriter sw = new StringWriter();
        final PrintWriter pw = new PrintWriter(sw);
        pw.println();
        thrown.printStackTrace(pw);
        pw.close();
        throwable = sw.toString();
    }

    return String.format(
            locale, format,
            date, source,
            record.getLoggerName(),
            Locale.ENGLISH == locale ? record.getLevel().getName() : record.getLevel().getLocalizedName(),
            message, throwable,
            sourceClassName == null ? source : sourceClassName,
            sourceMethodName == null ? source : sourceMethodName);
}
 
源代码15 项目: j2objc   文件: LocaleDataTest.java
public void testAll() throws Exception {
  // Test that we can get the locale data for all known locales.
  for (Locale l : Locale.getAvailableLocales()) {
    LocaleData d = LocaleData.get(l);
    // System.err.format("%20s %s %s %s\n", l, d.yesterday, d.today, d.tomorrow);
    // System.err.format("%20s %10s %10s\n", l, d.timeFormat_hm, d.timeFormat_Hm);
  }
}
 
源代码16 项目: JDKSourceCode1.8   文件: XMLDTDLoader.java
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value)
        throws XMLConfigurationException {
    if (propertyId.equals(SYMBOL_TABLE)) {
        fSymbolTable = (SymbolTable)value;
        fDTDScanner.setProperty(propertyId, value);
        fEntityManager.setProperty(propertyId, value);
    }
    else if(propertyId.equals(ERROR_REPORTER)) {
        fErrorReporter = (XMLErrorReporter)value;
        // Add XML message formatter if there isn't one.
        if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
            XMLMessageFormatter xmft = new XMLMessageFormatter();
            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
        }
        fDTDScanner.setProperty(propertyId, value);
        fEntityManager.setProperty(propertyId, value);
    }
    else if (propertyId.equals(ERROR_HANDLER)) {
        fErrorReporter.setProperty(propertyId, value);
    }
    else if (propertyId.equals(ENTITY_RESOLVER)) {
        fEntityResolver = (XMLEntityResolver)value;
        fEntityManager.setProperty(propertyId, value);
    }
    else if (propertyId.equals(LOCALE)) {
        setLocale((Locale) value);
    }
    else if(propertyId.equals(GRAMMAR_POOL)) {
        fGrammarPool = (XMLGrammarPool)value;
    }
    else {
        throw new XMLConfigurationException(Status.NOT_RECOGNIZED, propertyId);
    }
}
 
源代码17 项目: pcgen   文件: GenderLockTokenTest.java
@Test
public void testUnparseLegal()
{
	primaryProf.put(ObjectKey.GENDER_LOCK, Gender.Male);
	LocaleDependentTestCase.before(Locale.US);
	expectSingle(getToken().unparse(primaryContext, primaryProf), "Male");
	LocaleDependentTestCase.after();
	LocaleDependentTestCase.before(Locale.FRENCH);
	expectSingle(getToken().unparse(primaryContext, primaryProf), "Male");
	LocaleDependentTestCase.after();
}
 
/**
 * Formats a message with the specified arguments using the given
 * locale information.
 *
 * @param locale    The locale of the message.
 * @param key       The message key.
 * @param arguments The message replacement text arguments. The order
 *                  of the arguments must match that of the placeholders
 *                  in the actual message.
 *
 * @return Returns the formatted message.
 *
 * @throws MissingResourceException Thrown if the message with the
 *                                  specified key cannot be found.
 */
 public String formatMessage(Locale locale, String key, Object[] arguments)
    throws MissingResourceException {

    if (fResourceBundle == null || locale != fLocale) {
        if (locale != null) {
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages", locale);
            // memorize the most-recent locale
            fLocale = locale;
        }
        if (fResourceBundle == null)
            fResourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages");
    }

    String msg = fResourceBundle.getString(key);
    if (arguments != null) {
        try {
            msg = java.text.MessageFormat.format(msg, arguments);
        } catch (Exception e) {
            msg = fResourceBundle.getString("FormatFailed");
            msg += " " + fResourceBundle.getString(key);
        }
    }

    if (msg == null) {
        msg = fResourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg, "com.sun.org.apache.xerces.internal.impl.msg.XIncludeMessages", key);
    }

    return msg;
}
 
源代码19 项目: smarthome   文件: PersistenceServiceRegistryImpl.java
@Override
public Collection<ParameterOption> getParameterOptions(URI uri, String param, Locale locale) {
    if (uri.toString().equals("system:persistence") && param.equals("default")) {
        Set<ParameterOption> options = new HashSet<>();
        for (PersistenceService service : getAll()) {
            options.add(new ParameterOption(service.getId(), service.getLabel(locale)));
        }
        return options;
    }
    return null;
}
 
源代码20 项目: kafka-sample-programs   文件: Producer.java
public static void main(String[] args) throws IOException {
    // set up the producer
    KafkaProducer<String, String> producer;
    try (InputStream props = Resources.getResource("producer.props").openStream()) {
        Properties properties = new Properties();
        properties.load(props);
        producer = new KafkaProducer<>(properties);
    }

    try {
        for (int i = 0; i < 1000000; i++) {
            // send lots of messages
            producer.send(new ProducerRecord<String, String>(
                    "fast-messages",
                    String.format(Locale.US, "{\"type\":\"test\", \"t\":%.3f, \"k\":%d}", System.nanoTime() * 1e-9, i)));

            // every so often send to a different topic
            if (i % 1000 == 0) {
                producer.send(new ProducerRecord<String, String>(
                        "fast-messages",
                        String.format(Locale.US, "{\"type\":\"marker\", \"t\":%.3f, \"k\":%d}", System.nanoTime() * 1e-9, i)));
                producer.send(new ProducerRecord<String, String>(
                        "summary-markers",
                        String.format(Locale.US, "{\"type\":\"other\", \"t\":%.3f, \"k\":%d}", System.nanoTime() * 1e-9, i)));
                producer.flush();
                System.out.println("Sent msg number " + i);
            }
        }
    } catch (Throwable throwable) {
        System.out.printf("%s", throwable.getStackTrace());
    } finally {
        producer.close();
    }

}
 
@Override
public void sortAnime(List<AnimeBean> animaList, int sortType){
    if (sortType == SORT_FOLLOW){
        Collections.sort(animaList, (o1, o2) ->
                Boolean.compare(o2.isIsFavorited(), o1.isIsFavorited()));
    }else if (sortType == SORT_NAME){
        Collections.sort(animaList, (o1, o2) ->
                Collator.getInstance(Locale.CHINESE).compare( o1.getAnimeTitle(), o2.getAnimeTitle()));
    }else {
        Collections.sort(animaList, (o1, o2) ->
                Double.compare(o2.getRating(), o1.getRating()));
    }
}
 
源代码22 项目: mycore   文件: MCRContentServlet.java
@Override
protected void render(final MCRServletJob job, final Exception ex) throws Exception {
    if (ex != null) {
        throw ex;
    }
    final HttpServletRequest request = job.getRequest();
    final HttpServletResponse response = job.getResponse();
    final MCRContent content = getContent(request, response);
    boolean serveContent = MCRServletContentHelper.isServeContent(request);
    try {
        MCRServletContentHelper.serveContent(content, request, response, getServletContext(), getConfig(),
            serveContent);
    } catch (NoSuchFileException | FileNotFoundException e) {
        LOGGER.info("Catched {}:", e.getClass().getSimpleName(), e);
        response.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage());
        return;
    }

    final Supplier<Object> getResourceName = () -> {
        String id = "";
        if (Objects.nonNull(content.getSystemId())) {
            id = content.getSystemId();
        } else if (Objects.nonNull(content.getName())) {
            id = content.getName();
        }
        return String.format(Locale.ROOT, "Finished serving resource:%s", id);
    };
    LOGGER.debug(getResourceName);
}
 
源代码23 项目: kylin-on-parquet-v2   文件: JobService.java
protected JobInstance getCheckpointJobInstance(AbstractExecutable job) {
    Message msg = MsgPicker.getMsg();

    if (job == null) {
        return null;
    }
    if (!(job instanceof CheckpointExecutable)) {
        throw new BadRequestException(String.format(Locale.ROOT, msg.getILLEGAL_JOB_TYPE(), job.getId()));
    }

    CheckpointExecutable checkpointExecutable = (CheckpointExecutable) job;
    Output output = checkpointExecutable.getOutput();
    final JobInstance result = new JobInstance();
    result.setName(job.getName());
    result.setProjectName(checkpointExecutable.getProjectName());
    result.setRelatedCube(CubingExecutableUtil.getCubeName(job.getParams()));
    result.setDisplayCubeName(CubingExecutableUtil.getCubeName(job.getParams()));
    result.setLastModified(job.getLastModified());
    result.setSubmitter(job.getSubmitter());
    result.setUuid(job.getId());
    result.setExecStartTime(job.getStartTime());
    result.setExecEndTime(job.getEndTime());
    result.setExecInterruptTime(job.getInterruptTime());
    result.setType(CubeBuildTypeEnum.CHECKPOINT);
    result.setStatus(JobInfoConverter.parseToJobStatus(job.getStatus()));
    result.setBuildInstance(AbstractExecutable.getBuildInstance(output));
    result.setDuration(job.getDuration() / 1000);
    for (int i = 0; i < checkpointExecutable.getTasks().size(); ++i) {
        AbstractExecutable task = checkpointExecutable.getTasks().get(i);
        result.addStep(JobInfoConverter.parseToJobStep(task, i, getExecutableManager().getOutput(task.getId())));
    }
    return result;
}
 
源代码24 项目: Infinity-For-Reddit   文件: PostDataSource.java
PostDataSource(Retrofit retrofit, String accessToken, Locale locale, String path, int postType,
               SortType sortType, int filter, boolean nsfw) {
    this.retrofit = retrofit;
    this.accessToken = accessToken;
    this.locale = locale;
    if (postType == TYPE_SUBREDDIT) {
        this.subredditOrUserName = path;
    } else {
        if (sortType != null) {
            if (path.endsWith("/")) {
                multiRedditPath = path + sortType.getType().value;
            } else {
                multiRedditPath = path + "/" + sortType.getType().value;
            }
        } else {
            multiRedditPath = path;
        }
    }
    paginationNetworkStateLiveData = new MutableLiveData<>();
    initialLoadStateLiveData = new MutableLiveData<>();
    hasPostLiveData = new MutableLiveData<>();
    this.postType = postType;
    if (sortType == null) {
        if (path.equals("popular") || path.equals("all")) {
            this.sortType = new SortType(SortType.Type.HOT);
        } else {
            this.sortType = new SortType(SortType.Type.BEST);
        }
    } else {
        this.sortType = sortType;
    }
    this.filter = filter;
    this.nsfw = nsfw;
    postLinkedHashSet = new LinkedHashSet<>();
}
 
@Override
    protected void init(VaadinRequest request) {
    	setLocale(new Locale.Builder().setLanguage("sr").setScript("Latn").setRegion("RS").build());
    	
    	SecuredNavigator securedNavigator = new SecuredNavigator(MainUI.this, mainLayout, springViewProvider, security, eventBus);
        securedNavigator.addViewChangeListener(mainLayout);
        
        setContent(mainLayout);
        
        setErrorHandler(new SpringSecurityErrorHandler());
        
        /*
         * Handling redirections
         */        
//        RequestAttributes attrs = RequestContextHolder.getRequestAttributes();        
//        if (sessionStrategy.getAttribute(attrs, VaadinRedirectObject.REDIRECT_OBJECT_SESSION_ATTRIBUTE) != null) {        	
//        	VaadinRedirectObject redirectObject = (VaadinRedirectObject) sessionStrategy.getAttribute(attrs, VaadinRedirectObject.REDIRECT_OBJECT_SESSION_ATTRIBUTE);
//        	sessionStrategy.removeAttribute(attrs, VaadinRedirectObject.REDIRECT_OBJECT_SESSION_ATTRIBUTE);
//        	 
//        	navigator.navigateTo(redirectObject.getRedirectViewToken());
//        	
//        	if (redirectObject.getErrorMessage() != null) {
//        		Notification.show("Error", redirectObject.getErrorMessage(), Type.ERROR_MESSAGE);
//        	}
//        	
//        }
               
    }
 
private static int doToContractType(String typeString, String[] types, int[] values) {
  if (typeString == null) {
    return NO_TYPE;
  }
  for (int i = 0; i < types.length; i++) {
    String type = types[i];
    if (typeString.startsWith(type) || typeString.startsWith(type.toUpperCase(Locale.ENGLISH))) {
      return values[i];
    }
  }
  return NO_TYPE;
}
 
源代码27 项目: OpenMapKitAndroid   文件: Strings.java
static String millisToString(long millis, boolean text) {
    boolean negative = millis < 0;
    millis = java.lang.Math.abs(millis);

    millis /= 1000;
    int sec = (int) (millis % 60);
    millis /= 60;
    int min = (int) (millis % 60);
    millis /= 60;
    int hours = (int) millis;

    String time;
    DecimalFormat format = (DecimalFormat)NumberFormat.getInstance(Locale.US);
    format.applyPattern("00");
    if (text) {
        if (millis > 0)
            time = (negative ? "-" : "") + hours + "h" + format.format(min) + "min";
        else if (min > 0)
            time = (negative ? "-" : "") + min + "min";
        else
            time = (negative ? "-" : "") + sec + "s";
    }
    else {
        if (millis > 0)
            time = (negative ? "-" : "") + hours + ":" + format.format(min) + ":" + format.format(sec);
        else
            time = (negative ? "-" : "") + min + ":" + format.format(sec);
    }
    return time;
}
 
源代码28 项目: jdk8u60   文件: RichDiagnosticFormatter.java
@Override
public String visitCapturedType(CapturedType t, Locale locale) {
    if (getConfiguration().isEnabled(RichFormatterFeature.WHERE_CLAUSES)) {
        return localize(locale,
            "compiler.misc.captured.type",
            indexOf(t, WhereClauseKind.CAPTURED));
    }
    else
        return super.visitCapturedType(t, locale);
}
 
源代码29 项目: openhab-core   文件: MediaActionTypeProvider.java
/**
 * This method creates one option for every sink that is found in the system.
 *
 * @return a list of parameter options representing the audio sinks
 */
private List<ParameterOption> getSinkOptions(@Nullable Locale locale) {
    List<ParameterOption> options = new ArrayList<>();

    for (AudioSink sink : audioManager.getAllSinks()) {
        options.add(new ParameterOption(sink.getId(), sink.getLabel(locale)));
    }
    return options;
}
 
源代码30 项目: jdk8u-jdk   文件: DateTimeFormatterBuilder.java
/**
 * Gets the formatting pattern for date and time styles for a locale and chronology.
 * The locale and chronology are used to lookup the locale specific format
 * for the requested dateStyle and/or timeStyle.
 *
 * @param dateStyle  the FormatStyle for the date
 * @param timeStyle  the FormatStyle for the time
 * @param chrono  the Chronology, non-null
 * @param locale  the locale, non-null
 * @return the locale and Chronology specific formatting pattern
 * @throws IllegalArgumentException if both dateStyle and timeStyle are null
 */
public static String getLocalizedDateTimePattern(FormatStyle dateStyle, FormatStyle timeStyle,
        Chronology chrono, Locale locale) {
    Objects.requireNonNull(locale, "locale");
    Objects.requireNonNull(chrono, "chrono");
    if (dateStyle == null && timeStyle == null) {
        throw new IllegalArgumentException("Either dateStyle or timeStyle must be non-null");
    }
    LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased().getLocaleResources(locale);
    String pattern = lr.getJavaTimeDateTimePattern(
            convertStyle(timeStyle), convertStyle(dateStyle), chrono.getCalendarType());
    return pattern;
}