Java Code Examples for java.time.ZoneId#getDisplayName()

The following examples show how to use java.time.ZoneId#getDisplayName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Bug8024141.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    ZoneId gmt = ZoneId.of("GMT");
    String gmtName = gmt.getDisplayName(FULL, ENGLISH);
    String gmtAbbr = gmt.getDisplayName(SHORT, ENGLISH);

    for (String zone : ZONES) {
        ZoneId id = ZoneId.of(zone);
        String name = id.getDisplayName(FULL, ENGLISH);
        String abbr = id.getDisplayName(SHORT, ENGLISH);

        if (!name.equals(gmtName) || !abbr.equals(gmtAbbr)) {
            throw new RuntimeException("inconsistent name/abbr for " + zone + ":\n"
                                       + "name=" + name + ", abbr=" + abbr);
        }
    }
}
 
Example 2
Source File: Bug8024141.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    ZoneId gmt = ZoneId.of("GMT");
    String gmtName = gmt.getDisplayName(FULL, ENGLISH);
    String gmtAbbr = gmt.getDisplayName(SHORT, ENGLISH);

    for (String zone : ZONES) {
        ZoneId id = ZoneId.of(zone);
        String name = id.getDisplayName(FULL, ENGLISH);
        String abbr = id.getDisplayName(SHORT, ENGLISH);

        if (!name.equals(gmtName) || !abbr.equals(gmtAbbr)) {
            throw new RuntimeException("inconsistent name/abbr for " + zone + ":\n"
                                       + "name=" + name + ", abbr=" + abbr);
        }
    }
}
 
Example 3
Source File: Bug8024141.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    ZoneId gmt = ZoneId.of("GMT");
    String gmtName = gmt.getDisplayName(FULL, ENGLISH);
    String gmtAbbr = gmt.getDisplayName(SHORT, ENGLISH);

    for (String zone : ZONES) {
        ZoneId id = ZoneId.of(zone);
        String name = id.getDisplayName(FULL, ENGLISH);
        String abbr = id.getDisplayName(SHORT, ENGLISH);

        if (!name.equals(gmtName) || !abbr.equals(gmtAbbr)) {
            throw new RuntimeException("inconsistent name/abbr for " + zone + ":\n"
                                       + "name=" + name + ", abbr=" + abbr);
        }
    }
}
 
Example 4
Source File: Bug8024141.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    ZoneId gmt = ZoneId.of("GMT");
    String gmtName = gmt.getDisplayName(FULL, ENGLISH);
    String gmtAbbr = gmt.getDisplayName(SHORT, ENGLISH);

    for (String zone : ZONES) {
        ZoneId id = ZoneId.of(zone);
        String name = id.getDisplayName(FULL, ENGLISH);
        String abbr = id.getDisplayName(SHORT, ENGLISH);

        if (!name.equals(gmtName) || !abbr.equals(gmtAbbr)) {
            throw new RuntimeException("inconsistent name/abbr for " + zone + ":\n"
                                       + "name=" + name + ", abbr=" + abbr);
        }
    }
}
 
Example 5
Source File: Bug8024141.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    ZoneId gmt = ZoneId.of("GMT");
    String gmtName = gmt.getDisplayName(FULL, ENGLISH);
    String gmtAbbr = gmt.getDisplayName(SHORT, ENGLISH);

    for (String zone : ZONES) {
        ZoneId id = ZoneId.of(zone);
        String name = id.getDisplayName(FULL, ENGLISH);
        String abbr = id.getDisplayName(SHORT, ENGLISH);

        if (!name.equals(gmtName) || !abbr.equals(gmtAbbr)) {
            throw new RuntimeException("inconsistent name/abbr for " + zone + ":\n"
                                       + "name=" + name + ", abbr=" + abbr);
        }
    }
}
 
Example 6
Source File: Bug8024141.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    ZoneId gmt = ZoneId.of("GMT");
    String gmtName = gmt.getDisplayName(FULL, ENGLISH);
    String gmtAbbr = gmt.getDisplayName(SHORT, ENGLISH);

    for (String zone : ZONES) {
        ZoneId id = ZoneId.of(zone);
        String name = id.getDisplayName(FULL, ENGLISH);
        String abbr = id.getDisplayName(SHORT, ENGLISH);

        if (!name.equals(gmtName) || !abbr.equals(gmtAbbr)) {
            throw new RuntimeException("inconsistent name/abbr for " + zone + ":\n"
                                       + "name=" + name + ", abbr=" + abbr);
        }
    }
}
 
Example 7
Source File: Bug8024141.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    ZoneId gmt = ZoneId.of("GMT");
    String gmtName = gmt.getDisplayName(FULL, ENGLISH);
    String gmtAbbr = gmt.getDisplayName(SHORT, ENGLISH);

    for (String zone : ZONES) {
        ZoneId id = ZoneId.of(zone);
        String name = id.getDisplayName(FULL, ENGLISH);
        String abbr = id.getDisplayName(SHORT, ENGLISH);

        if (!name.equals(gmtName) || !abbr.equals(gmtAbbr)) {
            throw new RuntimeException("inconsistent name/abbr for " + zone + ":\n"
                                       + "name=" + name + ", abbr=" + abbr);
        }
    }
}
 
Example 8
Source File: Bug8024141.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    ZoneId gmt = ZoneId.of("GMT");
    String gmtName = gmt.getDisplayName(FULL, ENGLISH);
    String gmtAbbr = gmt.getDisplayName(SHORT, ENGLISH);

    for (String zone : ZONES) {
        ZoneId id = ZoneId.of(zone);
        String name = id.getDisplayName(FULL, ENGLISH);
        String abbr = id.getDisplayName(SHORT, ENGLISH);

        if (!name.equals(gmtName) || !abbr.equals(gmtAbbr)) {
            throw new RuntimeException("inconsistent name/abbr for " + zone + ":\n"
                                       + "name=" + name + ", abbr=" + abbr);
        }
    }
}
 
Example 9
Source File: Bug8024141.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    ZoneId gmt = ZoneId.of("GMT");
    String gmtName = gmt.getDisplayName(FULL, ENGLISH);
    String gmtAbbr = gmt.getDisplayName(SHORT, ENGLISH);

    for (String zone : ZONES) {
        ZoneId id = ZoneId.of(zone);
        String name = id.getDisplayName(FULL, ENGLISH);
        String abbr = id.getDisplayName(SHORT, ENGLISH);

        if (!name.equals(gmtName) || !abbr.equals(gmtAbbr)) {
            throw new RuntimeException("inconsistent name/abbr for " + zone + ":\n"
                                       + "name=" + name + ", abbr=" + abbr);
        }
    }
}
 
Example 10
Source File: Bug8024141.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    ZoneId gmt = ZoneId.of("GMT");
    String gmtName = gmt.getDisplayName(FULL, ENGLISH);
    String gmtAbbr = gmt.getDisplayName(SHORT, ENGLISH);

    for (String zone : ZONES) {
        ZoneId id = ZoneId.of(zone);
        String name = id.getDisplayName(FULL, ENGLISH);
        String abbr = id.getDisplayName(SHORT, ENGLISH);

        if (!name.equals(gmtName) || !abbr.equals(gmtAbbr)) {
            throw new RuntimeException("inconsistent name/abbr for " + zone + ":\n"
                                       + "name=" + name + ", abbr=" + abbr);
        }
    }
}
 
Example 11
Source File: Bug8024141.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    ZoneId gmt = ZoneId.of("GMT");
    String gmtName = gmt.getDisplayName(FULL, ENGLISH);
    String gmtAbbr = gmt.getDisplayName(SHORT, ENGLISH);

    for (String zone : ZONES) {
        ZoneId id = ZoneId.of(zone);
        String name = id.getDisplayName(FULL, ENGLISH);
        String abbr = id.getDisplayName(SHORT, ENGLISH);

        if (!name.equals(gmtName) || !abbr.equals(gmtAbbr)) {
            throw new RuntimeException("inconsistent name/abbr for " + zone + ":\n"
                                       + "name=" + name + ", abbr=" + abbr);
        }
    }
}
 
Example 12
Source File: Bug8024141.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    ZoneId gmt = ZoneId.of("GMT");
    String gmtName = gmt.getDisplayName(FULL, ENGLISH);
    String gmtAbbr = gmt.getDisplayName(SHORT, ENGLISH);

    for (String zone : ZONES) {
        ZoneId id = ZoneId.of(zone);
        String name = id.getDisplayName(FULL, ENGLISH);
        String abbr = id.getDisplayName(SHORT, ENGLISH);

        if (!name.equals(gmtName) || !abbr.equals(gmtAbbr)) {
            throw new RuntimeException("inconsistent name/abbr for " + zone + ":\n"
                                       + "name=" + name + ", abbr=" + abbr);
        }
    }
}
 
Example 13
Source File: Bug8024141.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    ZoneId gmt = ZoneId.of("GMT");
    String gmtName = gmt.getDisplayName(FULL, ENGLISH);
    String gmtAbbr = gmt.getDisplayName(SHORT, ENGLISH);

    for (String zone : ZONES) {
        ZoneId id = ZoneId.of(zone);
        String name = id.getDisplayName(FULL, ENGLISH);
        String abbr = id.getDisplayName(SHORT, ENGLISH);

        if (!name.equals(gmtName) || !abbr.equals(gmtAbbr)) {
            throw new RuntimeException("inconsistent name/abbr for " + zone + ":\n"
                                       + "name=" + name + ", abbr=" + abbr);
        }
    }
}
 
Example 14
Source File: FmtZoneId.java    From super-csv with Apache License 2.0 5 votes vote down vote up
/**
 * {@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);
}
 
Example 15
Source File: TimeZoneChooserValues.java    From datacollector with Apache License 2.0 3 votes vote down vote up
/**
   * Create user visible label for given zone id.
   *
   * The created labels are in format $OFFSET $SHORT ($NAME), e.g.
   *
   * +01:00 CET (Europe/Prague)
   * -07:00 PST (America/Los_Angeles)
   */
//  @VisibleForTesting
  static String getLabelForTimeZoneId(ZoneId zoneId) {
    ZoneOffset zos = LocalDateTime.now().atZone(zoneId).getOffset();

    return zos.getId().replaceAll("Z", "+00:00") + " " + zoneId.getDisplayName(TextStyle.SHORT, Locale.getDefault()) + " (" + zoneId.getId() + ")";
  }
 
Example 16
Source File: DateTimeExtensions.java    From groovy with Apache License 2.0 2 votes vote down vote up
/**
 * 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);
}
 
Example 17
Source File: DateTimeExtensions.java    From groovy with Apache License 2.0 2 votes vote down vote up
/**
 * 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);
}