本文整理了Java中java.util.Formatter.locale()
方法的一些代码示例,展示了Formatter.locale()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Formatter.locale()
方法的具体详情如下:
包路径:java.util.Formatter
类名称:Formatter
方法名:locale
[英]Returns the Locale of the Formatter.
[中]返回格式化程序的区域设置。
代码示例来源:origin: wildfly/wildfly
public JBossLogPrintWriter format(Locale l, String format, Object ... args) {
synchronized (lock) {
if ((formatter == null) || (formatter.locale() != l))
formatter = new Formatter(this, l);
formatter.format(l, format, args);
}
return this;
}
代码示例来源:origin: wildfly/wildfly
public JBossLogPrintWriter format(String format, Object ... args) {
synchronized (lock) {
if ((formatter == null)
|| (formatter.locale() != Locale.getDefault()))
formatter = new Formatter(this);
formatter.format(Locale.getDefault(), format, args);
}
return this;
}
代码示例来源:origin: qiujuer/Genius-Android
private String convertValueToMessage(int value) {
String format = mIndicatorFormatter != null ? mIndicatorFormatter : DEFAULT_FORMATTER;
//We're trying to re-use the Formatter here to avoid too much memory allocations
//But I'm not completey sure if it's doing anything good... :(
//Previously, this condition was wrong so the Formatter was always re-created
//But as I fixed the condition, the formatter started outputting trash characters from previous
//calls, so I mark the StringBuilder as empty before calling format again.
//Anyways, I see the memory usage still go up on every call to this method
//and I have no clue on how to fix that... damn Strings...
if (mFormatter == null || !mFormatter.locale().equals(Locale.getDefault())) {
int bufferSize = format.length() + String.valueOf(mMax).length();
if (mFormatBuilder == null) {
mFormatBuilder = new StringBuilder(bufferSize);
} else {
mFormatBuilder.ensureCapacity(bufferSize);
}
mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());
} else {
mFormatBuilder.setLength(0);
}
return mFormatter.format(format, value).toString();
}
代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel
@Override
public PrintWriter format(
Locale locale, String format, Object... arguments) {
if (_writer == null) {
_hasError = true;
}
else {
if ((_formatter == null) || (_formatter.locale() != locale)) {
_formatter = new Formatter(this, locale);
}
_formatter.format(locale, format, arguments);
}
return this;
}
代码示例来源:origin: DV8FromTheWorld/JDA
@Override
public void formatTo(Formatter formatter, int flags, int width, int precision)
{
boolean upper = (flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE;
boolean leftJustified = (flags & FormattableFlags.LEFT_JUSTIFY) == FormattableFlags.LEFT_JUSTIFY;
String out = content;
if (upper)
out = out.toUpperCase(formatter.locale());
appendFormat(formatter, width, precision, leftJustified, out);
}
代码示例来源:origin: DV8FromTheWorld/JDA
@Override
public void formatTo(Formatter formatter, int flags, int width, int precision)
{
boolean upper = (flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE;
boolean leftJustified = (flags & FormattableFlags.LEFT_JUSTIFY) == FormattableFlags.LEFT_JUSTIFY;
boolean alt = (flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE;
String out = alt ? getContentRaw() : getContentDisplay();
if (upper)
out = out.toUpperCase(formatter.locale());
appendFormat(formatter, width, precision, leftJustified, out);
}
代码示例来源:origin: DV8FromTheWorld/JDA
@Override
default void formatTo(Formatter formatter, int flags, int width, int precision)
{
boolean leftJustified = (flags & FormattableFlags.LEFT_JUSTIFY) == FormattableFlags.LEFT_JUSTIFY;
boolean upper = (flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE;
String out = upper ? getAsMention().toUpperCase(formatter.locale()) : getAsMention();
MiscUtil.appendTo(formatter, width, precision, leftJustified, out);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
if ((flags & java.util.FormattableFlags.UPPERCASE)
== java.util.FormattableFlags.UPPERCASE) {
l = l.toUpperCase(formatter.locale());
r = r.toUpperCase(formatter.locale());
代码示例来源:origin: DV8FromTheWorld/JDA
@Override
default void formatTo(Formatter formatter, int flags, int width, int precision)
{
boolean leftJustified = (flags & FormattableFlags.LEFT_JUSTIFY) == FormattableFlags.LEFT_JUSTIFY;
boolean upper = (flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE;
boolean alt = (flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE;
String out;
out = upper ? getName().toUpperCase(formatter.locale()) : getName();
if (alt)
out = "#" + out;
MiscUtil.appendTo(formatter, width, precision, leftJustified, out);
}
}
代码示例来源:origin: com.sun.mail/javax.mail
if ((flags & java.util.FormattableFlags.UPPERCASE)
== java.util.FormattableFlags.UPPERCASE) {
l = l.toUpperCase(formatter.locale());
r = r.toUpperCase(formatter.locale());
代码示例来源:origin: DV8FromTheWorld/JDA
@Override
public void formatTo(Formatter formatter, int flags, int width, int precision)
{
boolean alt = (flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE;
boolean upper = (flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE;
boolean leftJustified = (flags & FormattableFlags.LEFT_JUSTIFY) == FormattableFlags.LEFT_JUSTIFY;
String out;
if (!alt)
out = getAsMention();
else if (upper)
out = String.format(formatter.locale(), "%S#%s", getName(), getDiscriminator());
else
out = String.format(formatter.locale(), "%s#%s", getName(), getDiscriminator());
MiscUtil.appendTo(formatter, width, precision, leftJustified, out);
}
代码示例来源:origin: DV8FromTheWorld/JDA
@Override
default void formatTo(Formatter formatter, int flags, int width, int precision)
{
boolean leftJustified = (flags & FormattableFlags.LEFT_JUSTIFY) == FormattableFlags.LEFT_JUSTIFY;
boolean upper = (flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE;
boolean alt = (flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE;
String out;
if (alt)
out = "#" + (upper ? getName().toUpperCase(formatter.locale()) : getName());
else
out = getAsMention();
MiscUtil.appendTo(formatter, width, precision, leftJustified, out);
}
}
代码示例来源:origin: optimatika/ojAlgo
public Printer printf(final Locale locale, final String format, final Object... args) {
synchronized (myAppendable) {
if ((myFormatter == null) || (myFormatter.locale() != locale)) {
myFormatter = new Formatter(myAppendable, locale);
}
myFormatter.format(locale, format, args);
}
return this;
}
代码示例来源:origin: org.opencypher/grammar
@Override
public final Output format( Locale l, String format, Object... args )
{
if ( formatter == null || formatter.locale() != l )
{
formatter = new Formatter( this, l );
}
formatter.format( l, format, args );
return this;
}
}
代码示例来源:origin: org.ojalgo/ojalgo
public Printer printf(final Locale locale, final String format, final Object... args) {
synchronized (myAppendable) {
if ((myFormatter == null) || (myFormatter.locale() != locale)) {
myFormatter = new Formatter(myAppendable, locale);
}
myFormatter.format(locale, format, args);
}
return this;
}
代码示例来源:origin: optimatika/ojAlgo
public Printer printf(final String format, final Object... args) {
synchronized (myAppendable) {
if ((myFormatter == null) || (myFormatter.locale() != Locale.getDefault())) {
myFormatter = new Formatter(myAppendable);
}
myFormatter.format(Locale.getDefault(), format, args);
}
return this;
}
代码示例来源:origin: org.ojalgo/ojalgo
public Printer printf(final String format, final Object... args) {
synchronized (myAppendable) {
if ((myFormatter == null) || (myFormatter.locale() != Locale.getDefault())) {
myFormatter = new Formatter(myAppendable);
}
myFormatter.format(Locale.getDefault(), format, args);
}
return this;
}
代码示例来源:origin: org.jboss.eap/wildfly-connector
public JBossLogPrintWriter format(String format, Object ... args) {
synchronized (lock) {
if ((formatter == null)
|| (formatter.locale() != Locale.getDefault()))
formatter = new Formatter(this);
formatter.format(Locale.getDefault(), format, args);
}
return this;
}
代码示例来源:origin: org.opencypher/grammar
@Override
public final Output format( String format, Object... args )
{
if ( formatter == null || formatter.locale() != Locale.getDefault() )
{
formatter = new Formatter( this );
}
formatter.format( Locale.getDefault(), format, args );
return this;
}
代码示例来源:origin: pl.edu.icm.yadda/yadda-analysis-impl
public void dataFormat(String format, int size, Alignment padding, Object... args) {
StringBuilder sb = new StringBuilder();
Formatter tempFormatter = new Formatter(sb, formatter.locale());
tempFormatter.format(format, args);
data(sb.toString(), size, padding);
}
内容来源于网络,如有侵权,请联系作者删除!