Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 26615200B8A for ; Sat, 24 Sep 2016 17:03:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 24E4F160AD1; Sat, 24 Sep 2016 15:03:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 63DC6160ACA for ; Sat, 24 Sep 2016 17:03:09 +0200 (CEST) Received: (qmail 47705 invoked by uid 500); 24 Sep 2016 15:03:08 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 47688 invoked by uid 99); 24 Sep 2016 15:03:08 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Sep 2016 15:03:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1E816E00D6; Sat, 24 Sep 2016 15:03:08 +0000 (UTC) From: kaiyuanw To: issues@commons.apache.org Reply-To: issues@commons.apache.org References: In-Reply-To: Subject: [GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti... Content-Type: text/plain Message-Id: <20160924150308.1E816E00D6@git1-us-west.apache.org> Date: Sat, 24 Sep 2016 15:03:08 +0000 (UTC) archived-at: Sat, 24 Sep 2016 15:03:10 -0000 Github user kaiyuanw commented on a diff in the pull request: https://github.com/apache/commons-lang/pull/192#discussion_r80362427 --- Diff: src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java --- @@ -693,6 +693,43 @@ public void testToCalendar() { // expected } } + + //----------------------------------------------------------------------- + @Test + public void testToCalendarWithDate() { + assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date1, DateUtils.toCalendar(date1, zone).getTime()); + try { + DateUtils.toCalendar(null, zone); + fail("Expected NullPointerException to be thrown"); + } catch(final NullPointerException npe) { + // expected + } + } + + //----------------------------------------------------------------------- + @Test + public void testToCalendarWithTimeZone() { + assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the TimeZone back", zone, DateUtils.toCalendar(date1, zone).getTimeZone()); + try { + DateUtils.toCalendar(date1, null); + fail("Expected NullPointerException to be thrown"); + } catch(final NullPointerException npe) { + // expected + } + } + + //----------------------------------------------------------------------- + @Test + public void testToCalendarWithDateAndTimeZone() { + try { + Calendar c = DateUtils.toCalendar(date2, defaultZone); + assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date2, c.getTime()); + assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the TimeZone back", defaultZone, c.getTimeZone()); --- End diff -- Good point. Fixed. Please check. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---