734 //-----------------------------------------------------------------------
735 @Test(dataProvider="sampleToString")
736 public void test_parse(int y, int month, int d, int h, int m, int s, int n, String zoneId, String text) {
737 ZonedDateTime t = ZonedDateTime.parse(text);
738 assertEquals(t.getYear(), y);
739 assertEquals(t.getMonth().getValue(), month);
740 assertEquals(t.getDayOfMonth(), d);
741 assertEquals(t.getHour(), h);
742 assertEquals(t.getMinute(), m);
743 assertEquals(t.getSecond(), s);
744 assertEquals(t.getNano(), n);
745 assertEquals(t.getZone().getId(), zoneId);
746 }
747
748 @DataProvider(name="parseAdditional")
749 Object[][] data_parseAdditional() {
750 return new Object[][] {
751 {"2012-06-30T12:30:40Z[GMT]", 2012, 6, 30, 12, 30, 40, 0, "GMT"},
752 {"2012-06-30T12:30:40Z[UT]", 2012, 6, 30, 12, 30, 40, 0, "UT"},
753 {"2012-06-30T12:30:40Z[UTC]", 2012, 6, 30, 12, 30, 40, 0, "UTC"},
754 {"2012-06-30T12:30:40+01:00[Z]", 2012, 6, 30, 12, 30, 40, 0, "Z"},
755 {"2012-06-30T12:30:40+01:00[+01:00]", 2012, 6, 30, 12, 30, 40, 0, "+01:00"},
756 {"2012-06-30T12:30:40+01:00[GMT+01:00]", 2012, 6, 30, 12, 30, 40, 0, "GMT+01:00"},
757 {"2012-06-30T12:30:40+01:00[UT+01:00]", 2012, 6, 30, 12, 30, 40, 0, "UT+01:00"},
758 {"2012-06-30T12:30:40+01:00[UTC+01:00]", 2012, 6, 30, 12, 30, 40, 0, "UTC+01:00"},
759 {"2012-06-30T12:30:40-01:00[-01:00]", 2012, 6, 30, 12, 30, 40, 0, "-01:00"},
760 {"2012-06-30T12:30:40-01:00[GMT-01:00]", 2012, 6, 30, 12, 30, 40, 0, "GMT-01:00"},
761 {"2012-06-30T12:30:40-01:00[UT-01:00]", 2012, 6, 30, 12, 30, 40, 0, "UT-01:00"},
762 {"2012-06-30T12:30:40-01:00[UTC-01:00]", 2012, 6, 30, 12, 30, 40, 0, "UTC-01:00"},
763 {"2012-06-30T12:30:40+01:00[Europe/London]", 2012, 6, 30, 12, 30, 40, 0, "Europe/London"},
764 };
765 }
766
767 @Test(dataProvider="parseAdditional")
768 public void test_parseAdditional(String text, int y, int month, int d, int h, int m, int s, int n, String zoneId) {
769 ZonedDateTime t = ZonedDateTime.parse(text);
770 assertEquals(t.getYear(), y);
771 assertEquals(t.getMonth().getValue(), month);
772 assertEquals(t.getDayOfMonth(), d);
773 assertEquals(t.getHour(), h);
774 assertEquals(t.getMinute(), m);
|
734 //-----------------------------------------------------------------------
735 @Test(dataProvider="sampleToString")
736 public void test_parse(int y, int month, int d, int h, int m, int s, int n, String zoneId, String text) {
737 ZonedDateTime t = ZonedDateTime.parse(text);
738 assertEquals(t.getYear(), y);
739 assertEquals(t.getMonth().getValue(), month);
740 assertEquals(t.getDayOfMonth(), d);
741 assertEquals(t.getHour(), h);
742 assertEquals(t.getMinute(), m);
743 assertEquals(t.getSecond(), s);
744 assertEquals(t.getNano(), n);
745 assertEquals(t.getZone().getId(), zoneId);
746 }
747
748 @DataProvider(name="parseAdditional")
749 Object[][] data_parseAdditional() {
750 return new Object[][] {
751 {"2012-06-30T12:30:40Z[GMT]", 2012, 6, 30, 12, 30, 40, 0, "GMT"},
752 {"2012-06-30T12:30:40Z[UT]", 2012, 6, 30, 12, 30, 40, 0, "UT"},
753 {"2012-06-30T12:30:40Z[UTC]", 2012, 6, 30, 12, 30, 40, 0, "UTC"},
754 {"2012-06-30T12:30:40+01:00[Z]", 2012, 6, 30, 11, 30, 40, 0, "Z"},
755 {"2012-06-30T12:30:40+01:00[+01:00]", 2012, 6, 30, 12, 30, 40, 0, "+01:00"},
756 {"2012-06-30T12:30:40+01:00[GMT+01:00]", 2012, 6, 30, 12, 30, 40, 0, "GMT+01:00"},
757 {"2012-06-30T12:30:40+01:00[UT+01:00]", 2012, 6, 30, 12, 30, 40, 0, "UT+01:00"},
758 {"2012-06-30T12:30:40+01:00[UTC+01:00]", 2012, 6, 30, 12, 30, 40, 0, "UTC+01:00"},
759 {"2012-06-30T12:30:40-01:00[-01:00]", 2012, 6, 30, 12, 30, 40, 0, "-01:00"},
760 {"2012-06-30T12:30:40-01:00[GMT-01:00]", 2012, 6, 30, 12, 30, 40, 0, "GMT-01:00"},
761 {"2012-06-30T12:30:40-01:00[UT-01:00]", 2012, 6, 30, 12, 30, 40, 0, "UT-01:00"},
762 {"2012-06-30T12:30:40-01:00[UTC-01:00]", 2012, 6, 30, 12, 30, 40, 0, "UTC-01:00"},
763 {"2012-06-30T12:30:40+01:00[Europe/London]", 2012, 6, 30, 12, 30, 40, 0, "Europe/London"},
764 };
765 }
766
767 @Test(dataProvider="parseAdditional")
768 public void test_parseAdditional(String text, int y, int month, int d, int h, int m, int s, int n, String zoneId) {
769 ZonedDateTime t = ZonedDateTime.parse(text);
770 assertEquals(t.getYear(), y);
771 assertEquals(t.getMonth().getValue(), month);
772 assertEquals(t.getDayOfMonth(), d);
773 assertEquals(t.getHour(), h);
774 assertEquals(t.getMinute(), m);
|