在java中根据日期查找日期 - 给出错误的答案

use*_*218 0 java android date

java.util.Date给出错误的日期作为输出.

    java.util.Date date = new Date(2014,03,01);
    System.out.println("day is" +date.getDay());
Run Code Online (Sandbox Code Playgroud)

输出:天是3

实际上它应该是7

更新:非常感谢我能够获得输出这是我的代码

    java.util.Calendar c = java.util.Calendar.getInstance();
    c.clear();
    c.set(year,month,dd);
    System.out.println("day of week "+c.get(java.util.Calendar.DAY_OF_WEEK));
Run Code Online (Sandbox Code Playgroud)

And*_*kes 5

我想你想创建2014年3月1日的日期.但是你的构造函数调用你创建日期3914年4月1日!该API告诉你为什么:

A year y is represented by the integer y - 1900.
A month is represented by an integer from 0 to 11; 0 is January, 1 is February, and so forth; thus 11 is December.
A date (day of month) is represented by an integer from 1 to 31 in the usual manner.
Run Code Online (Sandbox Code Playgroud)

编辑:也不推荐使用此构造函数.请改用日历.