You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by kaiyuanw <gi...@git.apache.org> on 2016/09/21 05:03:08 UTC

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

GitHub user kaiyuanw opened a pull request:

    https://github.com/apache/commons-lang/pull/192

    Lang 1255: Add DateUtils.toCalendar(Date, TimeZone) and 3 unit tests

    Added new toCalendar method in DateUtils with 3 unit tests as proposed in LANG-1255.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/kaiyuanw/commons-lang lang-1255

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/commons-lang/pull/192.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #192
    
----
commit 1eecfc948bf6f4cbb9a2481313ca7368ec653056
Author: Kaiyuan Wang <wa...@gmail.com>
Date:   2016-09-21T04:58:36Z

    Add DateUtils.toCalendar(Date, TimeZone)

commit ac5a216f767c6defa4da720c6ecb3baa05e30254
Author: Kaiyuan Wang <wa...@gmail.com>
Date:   2016-09-21T04:59:04Z

    Add unit tests for DateUtils.toCalendar(Date, TimeZone)

----


---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by britter <gi...@git.apache.org>.
Github user britter commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80387226
  
    --- Diff: src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java ---
    @@ -693,6 +693,59 @@ public void testToCalendar() {
                 // expected
             }
         }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNotNull() {
    +        assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date1, DateUtils.toCalendar(date1, zone).getTime());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNull() {
    +        try {
    +            DateUtils.toCalendar(null, zone);
    +            fail("Expected NullPointerException to be thrown when Date is null");
    +        } catch(final NullPointerException npe) {
    +            // expected
    +        }
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithTimeZoneNotNull() {
    +    	assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the TimeZone back", zone, DateUtils.toCalendar(date1, zone).getTimeZone());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithTimeZoneNull() {
    +        try {
    +            DateUtils.toCalendar(date1, null);
    +            fail("Expected NullPointerException to be thrown when TimeZone is null");
    +        } catch(final NullPointerException npe) {
    +            // expected
    +        }
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateAndTimeZoneNotNull() {
    +    	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());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateAndTimeZoneNull() {
    +    	try {
    --- End diff --
    
    you don't need a try-catch here. You can simply use `@Test(expected=NullPointerException.class)`


---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/commons-lang/pull/192


---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by kaiyuanw <gi...@git.apache.org>.
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by britter <gi...@git.apache.org>.
Github user britter commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80387200
  
    --- Diff: src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java ---
    @@ -693,6 +693,59 @@ public void testToCalendar() {
                 // expected
             }
         }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNotNull() {
    +        assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date1, DateUtils.toCalendar(date1, zone).getTime());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNull() {
    +        try {
    --- End diff --
    
    you don't need a try-catch here. You can simply use `@Test(expected=NullPointerException.class)`


---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by britter <gi...@git.apache.org>.
Github user britter commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80387208
  
    --- Diff: src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java ---
    @@ -693,6 +693,59 @@ public void testToCalendar() {
                 // expected
             }
         }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNotNull() {
    +        assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date1, DateUtils.toCalendar(date1, zone).getTime());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNull() {
    +        try {
    +            DateUtils.toCalendar(null, zone);
    +            fail("Expected NullPointerException to be thrown when Date is null");
    +        } catch(final NullPointerException npe) {
    +            // expected
    +        }
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithTimeZoneNotNull() {
    +    	assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the TimeZone back", zone, DateUtils.toCalendar(date1, zone).getTimeZone());
    --- End diff --
    
    This test is redundant because we have `testToCalendarWithDateAndTimeZoneNotNull()`


---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by britter <gi...@git.apache.org>.
Github user britter commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80387206
  
    --- Diff: src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java ---
    @@ -693,6 +693,59 @@ public void testToCalendar() {
                 // expected
             }
         }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNotNull() {
    +        assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date1, DateUtils.toCalendar(date1, zone).getTime());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNull() {
    +        try {
    +            DateUtils.toCalendar(null, zone);
    +            fail("Expected NullPointerException to be thrown when Date is null");
    +        } catch(final NullPointerException npe) {
    +            // expected
    +        }
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithTimeZoneNotNull() {
    +    	assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the TimeZone back", zone, DateUtils.toCalendar(date1, zone).getTimeZone());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithTimeZoneNull() {
    +        try {
    --- End diff --
    
    you don't need a try-catch here. You can simply use `@Test(expected=NullPointerException.class)`


---
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.
---

[GitHub] commons-lang issue #192: Lang 1255: Add DateUtils.toCalendar(Date, TimeZone)...

Posted by britter <gi...@git.apache.org>.
Github user britter commented on the issue:

    https://github.com/apache/commons-lang/pull/192
  
    Thank you!


---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by britter <gi...@git.apache.org>.
Github user britter commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80387223
  
    --- Diff: src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java ---
    @@ -693,6 +693,59 @@ public void testToCalendar() {
                 // expected
             }
         }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNotNull() {
    +        assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date1, DateUtils.toCalendar(date1, zone).getTime());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNull() {
    +        try {
    +            DateUtils.toCalendar(null, zone);
    +            fail("Expected NullPointerException to be thrown when Date is null");
    +        } catch(final NullPointerException npe) {
    +            // expected
    +        }
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithTimeZoneNotNull() {
    +    	assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the TimeZone back", zone, DateUtils.toCalendar(date1, zone).getTimeZone());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithTimeZoneNull() {
    +        try {
    +            DateUtils.toCalendar(date1, null);
    +            fail("Expected NullPointerException to be thrown when TimeZone is null");
    +        } catch(final NullPointerException npe) {
    +            // expected
    +        }
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateAndTimeZoneNotNull() {
    +    	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());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateAndTimeZoneNull() {
    +    	try {
    +    		DateUtils.toCalendar(null, null);
    --- End diff --
    
    No tabs please.


---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by britter <gi...@git.apache.org>.
Github user britter commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80358033
  
    --- 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());
    +        	// expected
    +        } catch(final NullPointerException npe) {
    +        	fail("Expected NullPointerException to be thrown");
    --- End diff --
    
    I don't understand this code. Why is a `NullPointerException` expected at this point?


---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by britter <gi...@git.apache.org>.
Github user britter commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80358050
  
    --- 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 --
    
    This looks redundant to me, since `testToCalendarWithDate()` already tests that the date has been set and `testToCalendarWithTimeZone()` already tests, that the timeZone has been set.


---
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.
---

[GitHub] commons-lang issue #192: Lang 1255: Add DateUtils.toCalendar(Date, TimeZone)...

Posted by coveralls <gi...@git.apache.org>.
Github user coveralls commented on the issue:

    https://github.com/apache/commons-lang/pull/192
  
    
    [![Coverage Status](https://coveralls.io/builds/8035489/badge)](https://coveralls.io/builds/8035489)
    
    Coverage decreased (-0.0006%) to 93.528% when pulling **d9a2c69a9d1db6072e1d7b7ea4fcbd5c15d20b5d on kaiyuanw:lang-1255** into **db6f7c1d74ba64211221a69cfa9fe7171a9199e8 on apache:master**.



---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by kaiyuanw <gi...@git.apache.org>.
Github user kaiyuanw commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80387976
  
    --- Diff: src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java ---
    @@ -693,6 +693,59 @@ public void testToCalendar() {
                 // expected
             }
         }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNotNull() {
    --- End diff --
    
    Fixed.


---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by kaiyuanw <gi...@git.apache.org>.
Github user kaiyuanw commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80388001
  
    --- Diff: src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java ---
    @@ -693,6 +693,59 @@ public void testToCalendar() {
                 // expected
             }
         }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNotNull() {
    +        assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date1, DateUtils.toCalendar(date1, zone).getTime());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNull() {
    +        try {
    --- End diff --
    
    This is JUnit 4 feature.  I've fixed that but note that we cannot use JUnit 3 anymore.


---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by kaiyuanw <gi...@git.apache.org>.
Github user kaiyuanw commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80388060
  
    --- Diff: src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java ---
    @@ -693,6 +693,59 @@ public void testToCalendar() {
                 // expected
             }
         }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNotNull() {
    +        assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date1, DateUtils.toCalendar(date1, zone).getTime());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNull() {
    +        try {
    +            DateUtils.toCalendar(null, zone);
    +            fail("Expected NullPointerException to be thrown when Date is null");
    +        } catch(final NullPointerException npe) {
    +            // expected
    +        }
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithTimeZoneNotNull() {
    +    	assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the TimeZone back", zone, DateUtils.toCalendar(date1, zone).getTimeZone());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithTimeZoneNull() {
    +        try {
    +            DateUtils.toCalendar(date1, null);
    +            fail("Expected NullPointerException to be thrown when TimeZone is null");
    +        } catch(final NullPointerException npe) {
    +            // expected
    +        }
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateAndTimeZoneNotNull() {
    +    	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());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateAndTimeZoneNull() {
    +    	try {
    --- End diff --
    
    Fixed.


---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by britter <gi...@git.apache.org>.
Github user britter commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80387175
  
    --- Diff: src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java ---
    @@ -693,6 +693,59 @@ public void testToCalendar() {
                 // expected
             }
         }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNotNull() {
    --- End diff --
    
    This test is redundant because we have `testToCalendarWithDateAndTimeZoneNotNull()`


---
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.
---

[GitHub] commons-lang issue #192: Lang 1255: Add DateUtils.toCalendar(Date, TimeZone)...

Posted by kaiyuanw <gi...@git.apache.org>.
Github user kaiyuanw commented on the issue:

    https://github.com/apache/commons-lang/pull/192
  
    @britter Fixed.


---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by kaiyuanw <gi...@git.apache.org>.
Github user kaiyuanw commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80362430
  
    --- 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());
    +        	// expected
    +        } catch(final NullPointerException npe) {
    +        	fail("Expected NullPointerException to be thrown");
    --- End diff --
    
    That's a typo.  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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by kaiyuanw <gi...@git.apache.org>.
Github user kaiyuanw commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80388046
  
    --- Diff: src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java ---
    @@ -693,6 +693,59 @@ public void testToCalendar() {
                 // expected
             }
         }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNotNull() {
    +        assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date1, DateUtils.toCalendar(date1, zone).getTime());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNull() {
    +        try {
    +            DateUtils.toCalendar(null, zone);
    +            fail("Expected NullPointerException to be thrown when Date is null");
    +        } catch(final NullPointerException npe) {
    +            // expected
    +        }
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithTimeZoneNotNull() {
    +    	assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the TimeZone back", zone, DateUtils.toCalendar(date1, zone).getTimeZone());
    --- End diff --
    
    Removed.


---
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.
---

[GitHub] commons-lang issue #192: Lang 1255: Add DateUtils.toCalendar(Date, TimeZone)...

Posted by kaiyuanw <gi...@git.apache.org>.
Github user kaiyuanw commented on the issue:

    https://github.com/apache/commons-lang/pull/192
  
    @britter Your comments are handled and please check if it is good now.  Thank you.


---
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.
---

[GitHub] commons-lang issue #192: Lang 1255: Add DateUtils.toCalendar(Date, TimeZone)...

Posted by coveralls <gi...@git.apache.org>.
Github user coveralls commented on the issue:

    https://github.com/apache/commons-lang/pull/192
  
    
    [![Coverage Status](https://coveralls.io/builds/7980589/badge)](https://coveralls.io/builds/7980589)
    
    Coverage increased (+0.008%) to 93.537% when pulling **ac5a216f767c6defa4da720c6ecb3baa05e30254 on kaiyuanw:lang-1255** into **db6f7c1d74ba64211221a69cfa9fe7171a9199e8 on apache:master**.



---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by kaiyuanw <gi...@git.apache.org>.
Github user kaiyuanw commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80388061
  
    --- Diff: src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java ---
    @@ -693,6 +693,59 @@ public void testToCalendar() {
                 // expected
             }
         }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNotNull() {
    +        assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date1, DateUtils.toCalendar(date1, zone).getTime());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateNull() {
    +        try {
    +            DateUtils.toCalendar(null, zone);
    +            fail("Expected NullPointerException to be thrown when Date is null");
    +        } catch(final NullPointerException npe) {
    +            // expected
    +        }
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithTimeZoneNotNull() {
    +    	assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the TimeZone back", zone, DateUtils.toCalendar(date1, zone).getTimeZone());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithTimeZoneNull() {
    +        try {
    +            DateUtils.toCalendar(date1, null);
    +            fail("Expected NullPointerException to be thrown when TimeZone is null");
    +        } catch(final NullPointerException npe) {
    +            // expected
    +        }
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateAndTimeZoneNotNull() {
    +    	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());
    +    }
    +    
    +    //-----------------------------------------------------------------------
    +    @Test
    +    public void testToCalendarWithDateAndTimeZoneNull() {
    +    	try {
    +    		DateUtils.toCalendar(null, null);
    --- End diff --
    
    Fixed.


---
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.
---

[GitHub] commons-lang issue #192: Lang 1255: Add DateUtils.toCalendar(Date, TimeZone)...

Posted by coveralls <gi...@git.apache.org>.
Github user coveralls commented on the issue:

    https://github.com/apache/commons-lang/pull/192
  
    
    [![Coverage Status](https://coveralls.io/builds/8041353/badge)](https://coveralls.io/builds/8041353)
    
    Coverage increased (+0.02%) to 93.547% when pulling **8ac857c41ec8ae02e57eb0c1c1a012525e7e14b9 on kaiyuanw:lang-1255** into **db6f7c1d74ba64211221a69cfa9fe7171a9199e8 on apache:master**.



---
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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by kaiyuanw <gi...@git.apache.org>.
Github user kaiyuanw commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80362422
  
    --- Diff: src/main/java/org/apache/commons/lang3/time/DateUtils.java ---
    @@ -668,6 +668,19 @@ public static Calendar toCalendar(final Date date) {
         
         //-----------------------------------------------------------------------
         /**
    +     * Converts a {@code Date} of a given {@code TimeZone} into a {@code Calendar}
    +     * @param date the date to convert to a Calendar
    +     * @param timeZone the time zone of the @{code date}
    +     * @return
    --- End diff --
    
    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.
---

[GitHub] commons-lang pull request #192: Lang 1255: Add DateUtils.toCalendar(Date, Ti...

Posted by britter <gi...@git.apache.org>.
Github user britter commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/192#discussion_r80357986
  
    --- Diff: src/main/java/org/apache/commons/lang3/time/DateUtils.java ---
    @@ -668,6 +668,19 @@ public static Calendar toCalendar(final Date date) {
         
         //-----------------------------------------------------------------------
         /**
    +     * Converts a {@code Date} of a given {@code TimeZone} into a {@code Calendar}
    +     * @param date the date to convert to a Calendar
    +     * @param timeZone the time zone of the @{code date}
    +     * @return
    --- End diff --
    
    Missing JavaDoc


---
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.
---