< prev index next >

test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java

Print this page


   1 /*
   2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 607         return new Object[][] {
 608             {HijrahChronology.INSTANCE.date(1434, 6, 26), LocalDate.of(2013, 5, 5), -1, 1},
 609             {HijrahChronology.INSTANCE.date(1433, 4, 15), LocalDate.of(2012, 3, 15), 1, -1},
 610             {HijrahChronology.INSTANCE.date(1432, 5, 21), LocalDate.of(2011, 4, 22), -1, 1},
 611             {HijrahChronology.INSTANCE.date(1433, 7, 29), LocalDate.of(2012, 6, 2), -1, 1},
 612             {HijrahChronology.INSTANCE.date(1434, 10, 12), LocalDate.of(2013, 8, 2), -1, 1},
 613         };
 614     }
 615 
 616     // Test to compare dates in both forward and reverse order
 617     @Test(dataProvider="datesForComparison")
 618     public void test_compareDates(HijrahDate hdate, LocalDate ldate, int result1, int result2) {
 619         assertEquals(ldate.compareTo(hdate), result1);
 620         assertEquals(hdate.compareTo(ldate), result2);
 621     }
 622 
 623     // Test to verify the values of various chrono fields for a given hijrah date instance
 624     @Test
 625     public void test_chronoFields() {
 626         ChronoLocalDate hdate = HijrahChronology.INSTANCE.date(1434, 6, 28);
 627         assertEquals(hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH), 3);
 628         assertEquals(hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR), 7);
 629         assertEquals(hdate.get(ChronoField.ALIGNED_WEEK_OF_MONTH), 4);
 630         assertEquals(hdate.get(ChronoField.ALIGNED_WEEK_OF_YEAR), 25);
 631         assertEquals(hdate.get(ChronoField.ERA), 1);
 632         assertEquals(hdate.get(ChronoField.YEAR_OF_ERA), 1434);
 633         assertEquals(hdate.get(ChronoField.MONTH_OF_YEAR), 6);
 634         assertEquals(hdate.get(ChronoField.DAY_OF_MONTH), 28);
 635         assertEquals(hdate.get(ChronoField.DAY_OF_WEEK), 3);
 636         assertEquals(hdate.get(ChronoField.DAY_OF_YEAR), 175);
 637     }
 638 
 639     // Test to verify the returned hijrah date after adjusting the day of week as Saturday
 640     @Test
 641     public void test_adjustInto() {
 642         assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 6, 28)), HijrahDate.of(1434, 7, 1));
 643         assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1432, 4, 13)), HijrahDate.of(1432, 4, 14));
 644         assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1433, 11, 29)), HijrahDate.of(1433, 12, 4));
 645         assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 5, 10)), HijrahDate.of(1434, 5, 11));
 646         assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 9, 11)), HijrahDate.of(1434, 9, 12));
 647     }


   1 /*
   2  * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 607         return new Object[][] {
 608             {HijrahChronology.INSTANCE.date(1434, 6, 26), LocalDate.of(2013, 5, 5), -1, 1},
 609             {HijrahChronology.INSTANCE.date(1433, 4, 15), LocalDate.of(2012, 3, 15), 1, -1},
 610             {HijrahChronology.INSTANCE.date(1432, 5, 21), LocalDate.of(2011, 4, 22), -1, 1},
 611             {HijrahChronology.INSTANCE.date(1433, 7, 29), LocalDate.of(2012, 6, 2), -1, 1},
 612             {HijrahChronology.INSTANCE.date(1434, 10, 12), LocalDate.of(2013, 8, 2), -1, 1},
 613         };
 614     }
 615 
 616     // Test to compare dates in both forward and reverse order
 617     @Test(dataProvider="datesForComparison")
 618     public void test_compareDates(HijrahDate hdate, LocalDate ldate, int result1, int result2) {
 619         assertEquals(ldate.compareTo(hdate), result1);
 620         assertEquals(hdate.compareTo(ldate), result2);
 621     }
 622 
 623     // Test to verify the values of various chrono fields for a given hijrah date instance
 624     @Test
 625     public void test_chronoFields() {
 626         ChronoLocalDate hdate = HijrahChronology.INSTANCE.date(1434, 6, 28);
 627         assertEquals(hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH), 7);
 628         assertEquals(hdate.get(ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR), 7);
 629         assertEquals(hdate.get(ChronoField.ALIGNED_WEEK_OF_MONTH), 4);
 630         assertEquals(hdate.get(ChronoField.ALIGNED_WEEK_OF_YEAR), 25);
 631         assertEquals(hdate.get(ChronoField.ERA), 1);
 632         assertEquals(hdate.get(ChronoField.YEAR_OF_ERA), 1434);
 633         assertEquals(hdate.get(ChronoField.MONTH_OF_YEAR), 6);
 634         assertEquals(hdate.get(ChronoField.DAY_OF_MONTH), 28);
 635         assertEquals(hdate.get(ChronoField.DAY_OF_WEEK), 3);
 636         assertEquals(hdate.get(ChronoField.DAY_OF_YEAR), 175);
 637     }
 638 
 639     // Test to verify the returned hijrah date after adjusting the day of week as Saturday
 640     @Test
 641     public void test_adjustInto() {
 642         assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 6, 28)), HijrahDate.of(1434, 7, 1));
 643         assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1432, 4, 13)), HijrahDate.of(1432, 4, 14));
 644         assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1433, 11, 29)), HijrahDate.of(1433, 12, 4));
 645         assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 5, 10)), HijrahDate.of(1434, 5, 11));
 646         assertEquals(DayOfWeek.SATURDAY.adjustInto(HijrahDate.of(1434, 9, 11)), HijrahDate.of(1434, 9, 12));
 647     }


< prev index next >