test/java/time/test/java/time/TestOffsetDateTime.java

Print this page

        

*** 55,79 **** * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ! package test.java.time.temporal; import static org.testng.Assert.assertSame; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZoneOffset; ! import java.time.temporal.OffsetDateTime; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; - import test.java.time.AbstractTest; - import test.java.time.MockSimplePeriod; /** * Test OffsetDateTime. */ @Test --- 55,77 ---- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ! package test.java.time; import static org.testng.Assert.assertSame; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.ZoneOffset; ! import java.time.OffsetDateTime; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** * Test OffsetDateTime. */ @Test
*** 112,134 **** LocalTime localTime = LocalTime.of(h, m, s, n); LocalDateTime localDateTime = LocalDateTime.of(localDate, localTime); OffsetDateTime a = OffsetDateTime.of(localDateTime, offset); assertSame(a.getOffset(), offset); ! assertSame(a.getDate(), localDate); ! assertSame(a.getTime(), localTime); ! assertSame(a.getDateTime(), localDateTime); } //----------------------------------------------------------------------- // withOffsetSameLocal() //----------------------------------------------------------------------- @Test(groups={"implementation"}) public void test_withOffsetSameLocal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withOffsetSameLocal(OFFSET_PTWO); ! assertSame(test.getDateTime(), base.getDateTime()); assertSame(test.getOffset(), OFFSET_PTWO); } @Test(groups={"implementation"}) public void test_withOffsetSameLocal_noChange() { --- 110,132 ---- LocalTime localTime = LocalTime.of(h, m, s, n); LocalDateTime localDateTime = LocalDateTime.of(localDate, localTime); OffsetDateTime a = OffsetDateTime.of(localDateTime, offset); assertSame(a.getOffset(), offset); ! assertSame(a.toLocalDate(), localDate); ! assertSame(a.toLocalTime(), localTime); ! assertSame(a.toLocalDateTime(), localDateTime); } //----------------------------------------------------------------------- // withOffsetSameLocal() //----------------------------------------------------------------------- @Test(groups={"implementation"}) public void test_withOffsetSameLocal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withOffsetSameLocal(OFFSET_PTWO); ! assertSame(test.toLocalDateTime(), base.toLocalDateTime()); assertSame(test.getOffset(), OFFSET_PTWO); } @Test(groups={"implementation"}) public void test_withOffsetSameLocal_noChange() {