JDK-4878119 : Calendar.get(Calendar.HOUR) returns 0 for the midnight hour, not 12
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.4.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2003-06-12
  • Updated: 2003-12-03
  • Resolved: 2003-12-03
Related Reports
Duplicate :  
Description

Name: nt126004			Date: 06/12/2003


FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
on the 12 hour clock the hour after midnight is 12am, but Calendar.get(Calendar.HOUR) returns 0, not 12 for a time set in that hour.
It seems that this should be the behavior for HOUR_OF_DAY, but HOUR should
return 12.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile and run below code

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.*;                                                             
public class BadDate {
        public static void main(String[] args) {
                Calendar am = Calendar.getInstance(), pm = Calendar.getInstance(
);

                am.set(2003, 04, 22, 0, 15, 5); // midnight hour
                pm.set(2003, 04, 22, 12, 15, 5); // noon hour
                System.out.println(am.get(Calendar.HOUR));
                System.out.println(am.get(Calendar.HOUR_OF_DAY));
                System.out.println(pm.get(Calendar.HOUR));
                System.out.println(pm.get(Calendar.HOUR_OF_DAY));
        }
}
---------- END SOURCE ----------
(Review ID: 186444) 
======================================================================

Comments
EVALUATION This is a duplicate of 4690258. ###@###.### 2003-12-03
03-12-2003