本文整理了Java中java.time.ZoneId.getDisplayName()
方法的一些代码示例,展示了ZoneId.getDisplayName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneId.getDisplayName()
方法的具体详情如下:
包路径:java.time.ZoneId
类名称:ZoneId
方法名:getDisplayName
[英]Gets the textual representation of the zone, such as 'British Time' or '+02:00'.
This returns the textual name used to identify the time-zone ID, suitable for presentation to the user. The parameters control the style of the returned text and the locale.
If no textual mapping is found then the #getId() is returned.
[中]获取区域的文本表示形式,例如“英国时间”或“+02:00”。
这将返回用于标识时区ID的文本名称,适合向用户演示。这些参数控制返回文本的样式和区域设置。
如果没有找到文本映射,则返回#getId()。
代码示例来源:origin: stackoverflow.com
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.TextStyle;
import java.util.Locale;
import java.util.Set;
Set<String> zoneIds = ZoneId.getAvailableZoneIds();
for (String zoneId : zoneIds) {
ZoneId zone = ZoneId.of(zoneId);
ZonedDateTime zonedDateTime = ZonedDateTime.now(zone);
ZoneOffset offset = zonedDateTime.getOffset();
String longName = zone.getDisplayName(TextStyle.FULL, Locale.ENGLISH);
System.out.println("(" + offset + ") " + zoneId + ", " + longName);
}
代码示例来源:origin: rakam-io/rakam
if (applyZone) {
finalQuery = format("set time zone '%s'",
checkLiteral(zoneId.getDisplayName(NARROW, ENGLISH))) + "; " + query;
} else {
finalQuery = query;
代码示例来源:origin: org.codehaus.groovy/groovy-datetime
/**
* Returns the name of this zone formatted according to the {@link java.time.format.TextStyle#FULL} text style
* for the provided {@link java.util.Locale}.
*
* @param self a ZoneId
* @param locale a Locale
* @return the full display name of the ZoneId
* @since 2.5.0
*/
public static String getFullName(final ZoneId self, Locale locale) {
return self.getDisplayName(TextStyle.FULL, locale);
}
代码示例来源:origin: org.codehaus.groovy/groovy-datetime
/**
* Returns the name of this zone formatted according to the {@link java.time.format.TextStyle#SHORT} text style
* for the provided {@link java.util.Locale}.
*
* @param self a ZoneId
* @param locale a Locale
* @return the short display name of the ZoneId
* @since 2.5.0
*/
public static String getShortName(final ZoneId self, Locale locale) {
return self.getDisplayName(TextStyle.SHORT, locale);
}
代码示例来源:origin: alblue/com.packtpub.e4
public String getText(Object element) {
if (element instanceof ZoneId) {
return ((ZoneId) element).getDisplayName(TextStyle.FULL, Locale.getDefault());
} else {
return "";
}
}
代码示例来源:origin: alblue/com.packtpub.e4
public boolean select(Viewer v, Object parent, Object element) {
if (element instanceof ZoneId) {
ZoneId zone = (ZoneId) element;
String displayName = zone.getDisplayName(TextStyle.FULL, Locale.getDefault());
return displayName.contains(pattern);
} else {
return true;
}
}
}
代码示例来源:origin: nielsbasjes/logparser
public DateTimeFormatter build() {
DateTimeFormatter dateTimeFormatter = builder.toFormatter();
if (!zoneWasSpecified) {
dateTimeFormatter = dateTimeFormatter.withZone(defaultZone);
LOG.warn("The timestamp format \"{}\" does NOT contain a timezone so we assume \"{}\".",
strfformat, defaultZone.getDisplayName(TextStyle.SHORT, Locale.ENGLISH));
}
return dateTimeFormatter;
}
代码示例来源:origin: amedia/freemarker-java-8
@Override
public Object exec(List list) throws TemplateModelException {
return getObject().getDisplayName(findTextStyle(list), findLocale(list));
}
代码示例来源:origin: amedia/freemarker-java-8
@Override
public String getAsString() throws TemplateModelException {
return getObject().getDisplayName(TextStyle.FULL, Environment.getCurrentEnvironment().getLocale());
}
代码示例来源:origin: jpos/jPOS
p.printf("%s encoding: %s%n", indent, Charset.defaultCharset());
p.printf("%s timezone: %s (%s) %s%n", indent, zi,
zi.getDisplayName(TextStyle.FULL, Locale.getDefault()),
zi.getRules().getOffset(instant).toString());
p.printf("%swatch service: %s%n", indent, getServer().getWatchServiceClassname());
代码示例来源:origin: net.sf.supercsv/super-csv-java8
/**
* {@inheritDoc}
*
* @throws SuperCsvCellProcessorException if value is null or not a ZoneId
*/
public Object execute(final Object value, final CsvContext context) {
validateInputNotNull(value, context);
if( !(value instanceof ZoneId) ) {
throw new SuperCsvCellProcessorException(ZoneId.class, value, context, this);
}
final ZoneId zoneId = (ZoneId) value;
final String result;
if (textStyle != null && locale != null) {
result = zoneId.getDisplayName(textStyle, locale);
} else {
result = zoneId.toString();
}
return next.execute(result, context);
}
代码示例来源:origin: jpos/jPOS
public void exec(CLIContext cli, String[] args) throws Exception
{
ZoneId zi = ZoneId.systemDefault();
Instant i = Instant.now();
cli.println(
" Zone ID: " + zi + " (" + zi.getDisplayName(TextStyle.FULL, Locale.getDefault()) + ") "
+ zi.getRules().getOffset(i)
);
cli.println (" UTC: " + i);
ZoneOffsetTransition tran = zi.getRules().nextTransition(i);
if (tran != null) {
Instant in = tran.getInstant();
cli.println (" Next transition: " + in + " (" + in.atZone(zi) + ")");
}
List<ZoneOffsetTransitionRule> l = zi.getRules().getTransitionRules();
for (ZoneOffsetTransitionRule r : l) {
cli.println (" Transition rule: " + r);
}
}
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.11
public static DashboardConfiguration from(long refreshInterval, ZonedDateTime zonedDateTime) {
final String flinkVersion = EnvironmentInformation.getVersion();
final EnvironmentInformation.RevisionInformation revision = EnvironmentInformation.getRevisionInformation();
final String flinkRevision;
if (revision != null) {
flinkRevision = revision.commitId + " @ " + revision.commitDate;
} else {
flinkRevision = "unknown revision";
}
return new DashboardConfiguration(
refreshInterval,
zonedDateTime.getZone().getDisplayName(TextStyle.FULL, Locale.getDefault()),
// convert zone date time into offset in order to not do the day light saving adaptions wrt the offset
zonedDateTime.toOffsetDateTime().getOffset().getTotalSeconds() * 1000,
flinkVersion,
flinkRevision);
}
}
代码示例来源:origin: org.apache.flink/flink-runtime
public static DashboardConfiguration from(long refreshInterval, ZonedDateTime zonedDateTime) {
final String flinkVersion = EnvironmentInformation.getVersion();
final EnvironmentInformation.RevisionInformation revision = EnvironmentInformation.getRevisionInformation();
final String flinkRevision;
if (revision != null) {
flinkRevision = revision.commitId + " @ " + revision.commitDate;
} else {
flinkRevision = "unknown revision";
}
return new DashboardConfiguration(
refreshInterval,
zonedDateTime.getZone().getDisplayName(TextStyle.FULL, Locale.getDefault()),
// convert zone date time into offset in order to not do the day light saving adaptions wrt the offset
zonedDateTime.toOffsetDateTime().getOffset().getTotalSeconds() * 1000,
flinkVersion,
flinkRevision);
}
}
代码示例来源:origin: com.alibaba.blink/flink-runtime
public static DashboardConfiguration from(long refreshInterval, ZonedDateTime zonedDateTime) {
final String flinkVersion = EnvironmentInformation.getVersion();
final EnvironmentInformation.RevisionInformation revision = EnvironmentInformation.getRevisionInformation();
final String flinkRevision;
if (revision != null) {
flinkRevision = revision.commitId + " @ " + revision.commitDate;
} else {
flinkRevision = "unknown revision";
}
return new DashboardConfiguration(
refreshInterval,
zonedDateTime.getZone().getDisplayName(TextStyle.FULL, Locale.getDefault()),
// convert zone date time into offset in order to not do the day light saving adaptions wrt the offset
zonedDateTime.toOffsetDateTime().getOffset().getTotalSeconds() * 1000,
flinkVersion,
flinkRevision);
}
}
代码示例来源:origin: com.helger/ph-oton-bootstrap3-pages
aCurrentDTZ.getId () +
" - " +
aCurrentDTZ.getDisplayName (TextStyle.FULL,
aDisplayLocale)));
final HCTable aTable = new HCTable (new DTCol (EText.MSG_ID.getDisplayText (aDisplayLocale)).setInitialSorting (ESortOrder.ASCENDING),
aRow.addCell (aDTZ.getDisplayName (TextStyle.FULL, aDisplayLocale));
aRow.addCell (aDTZ.getDisplayName (TextStyle.SHORT, aDisplayLocale));
aRow.addCell (Duration.ofSeconds (aZO.getTotalSeconds ()).toString ());
aRow.addCell (EPhotonCoreText.getYesOrNo (aZR.isFixedOffset (), aDisplayLocale));
代码示例来源:origin: com.helger/ph-oton-bootstrap4-pages
aCurrentDTZ.getId () +
" - " +
aCurrentDTZ.getDisplayName (TextStyle.FULL,
aDisplayLocale)));
final HCTable aTable = new HCTable (new DTCol (EText.MSG_ID.getDisplayText (aDisplayLocale)).setInitialSorting (ESortOrder.ASCENDING),
aRow.addCell (aDTZ.getDisplayName (TextStyle.FULL, aDisplayLocale));
aRow.addCell (aDTZ.getDisplayName (TextStyle.SHORT, aDisplayLocale));
aRow.addCell (Duration.ofSeconds (aZO.getTotalSeconds ()).toString ());
aRow.addCell (EPhotonCoreText.getYesOrNo (aZR.isFixedOffset (), aDisplayLocale));
代码示例来源:origin: nielsbasjes/logparser
dateTime.getZone().getDisplayName(TextStyle.FULL, locale));
内容来源于网络,如有侵权,请联系作者删除!