Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class StrftimeFormatter {
CONVERSIONS['y'] = "yy";
CONVERSIONS['Y'] = "yyyy";
CONVERSIONS['z'] = "Z";
CONVERSIONS['Z'] = "ZZZZ";
CONVERSIONS['Z'] = "z";
CONVERSIONS['%'] = "%";

NOMINATIVE_CONVERSIONS['B'] = "LLLL";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ public void itSupportsTimezones() throws Exception {
assertThat(filter.filter(1539277785000L, interpreter, "%B %d, %Y, at %I:%M %p", "UTC+8")).isEqualTo("October 12, 2018, at 01:09 AM");
}

@Test
public void itOutputsTimezoneName() {
assertThat(filter.filter(1539277785000L, interpreter, "%l:%M %p %Z", "America/Los_Angeles")).isEqualTo("10:09 AM PDT");
}

@Test
public void itOutputsTimezoneOffset() {
assertThat(filter.filter(1539277785000L, interpreter, "%l:%M %p %z", "America/Los_Angeles")).isEqualTo("10:09 AM -0700");
}

@Test(expected = InvalidDateFormatException.class)
public void itThrowsExceptionOnInvalidTimezone() throws Exception {
filter.filter(1539277785000L, interpreter, "%B %d, %Y, at %I:%M %p", "Not a timezone");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Locale;

Expand Down Expand Up @@ -85,8 +86,9 @@ public void testFinnishMonths() {

@Test
public void testZoneOutput() {
assertThat(StrftimeFormatter.format(d, "%z")).isEqualTo("+0000");
assertThat(StrftimeFormatter.format(d, "%Z")).isEqualTo("GMT");
d = ZonedDateTime.of(d.toLocalDateTime(), ZoneId.of("America/Los_Angeles"));
assertThat(StrftimeFormatter.format(d, "%z")).isEqualTo("-0800");
assertThat(StrftimeFormatter.format(d, "%Z")).isEqualTo("PST");
}

@Test
Expand Down