Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/main/java/org/threeten/bp/ZoneId.java
Original file line number Diff line number Diff line change
Expand Up @@ -474,26 +474,26 @@ public static ZoneId from(TemporalAccessor temporal) {
* @param locale the locale to use, not null
* @return the text value of the zone, not null
*/
public String getDisplayName(TextStyle style, Locale locale) {
return new DateTimeFormatterBuilder().appendZoneText(style).toFormatter(locale).format(new DefaultInterfaceTemporalAccessor() {
@Override
public boolean isSupported(TemporalField field) {
return false;
}
@Override
public long getLong(TemporalField field) {
throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
}
@SuppressWarnings("unchecked")
@Override
public <R> R query(TemporalQuery<R> query) {
if (query == TemporalQueries.zoneId()) {
return (R) ZoneId.this;
}
return super.query(query);
}
});
}
// public String getDisplayName(TextStyle style, Locale locale) {
// return new DateTimeFormatterBuilder().appendZoneText(style).toFormatter(locale).format(new DefaultInterfaceTemporalAccessor() {
// @Override
// public boolean isSupported(TemporalField field) {
// return false;
// }
// @Override
// public long getLong(TemporalField field) {
// throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
// }
// @SuppressWarnings("unchecked")
// @Override
// public <R> R query(TemporalQuery<R> query) {
// if (query == TemporalQueries.zoneId()) {
// return (R) ZoneId.this;
// }
// return super.query(query);
// }
// });
// }

/**
* Normalizes the time-zone ID, returning a {@code ZoneOffset} where possible.
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/threeten/bp/TestZoneId.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void test_serialization_format() throws ClassNotFoundException, IOExcepti
public void test_constant_UTC() {
ZoneId test = ZoneOffset.UTC;
assertEquals(test.getId(), "Z");
assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), "Z");
// assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), "Z");
assertEquals(test.getRules().isFixedOffset(), true);
assertEquals(test.getRules().getOffset(Instant.ofEpochSecond(0L)), ZoneOffset.UTC);
checkOffset(test.getRules(), createLDT(2008, 6, 30), ZoneOffset.UTC, 1);
Expand Down Expand Up @@ -289,7 +289,7 @@ public void test_of_string_offset(String input, String id) {
public void test_of_string_FixedUTC(String input, String id) {
ZoneId test = ZoneId.of("UTC" + input);
assertEquals(test.getId(), "UTC" + id);
assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), "UTC" + id);
//assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), "UTC" + id);
assertEquals(test.getRules().isFixedOffset(), true);
ZoneOffset offset = ZoneOffset.of(id.isEmpty() ? "Z" : id);
assertEquals(test.getRules().getOffset(Instant.ofEpochSecond(0L)), offset);
Expand All @@ -300,7 +300,7 @@ public void test_of_string_FixedUTC(String input, String id) {
public void test_of_string_FixedGMT(String input, String id) {
ZoneId test = ZoneId.of("GMT" + input);
assertEquals(test.getId(), "GMT" + id);
assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), "GMT" + id);
//assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), "GMT" + id);
assertEquals(test.getRules().isFixedOffset(), true);
ZoneOffset offset = ZoneOffset.of(id.isEmpty() ? "Z" : id);
assertEquals(test.getRules().getOffset(Instant.ofEpochSecond(0L)), offset);
Expand All @@ -311,7 +311,7 @@ public void test_of_string_FixedGMT(String input, String id) {
public void test_of_string_FixedUT(String input, String id) {
ZoneId test = ZoneId.of("UT" + input);
assertEquals(test.getId(), "UT" + id);
assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), "UT" + id);
//assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), "UT" + id);
assertEquals(test.getRules().isFixedOffset(), true);
ZoneOffset offset = ZoneOffset.of(id.isEmpty() ? "Z" : id);
assertEquals(test.getRules().getOffset(Instant.ofEpochSecond(0L)), offset);
Expand Down