![](/img/trans.png)
[英]Java Lab: Trying to figure where I went wrong. My output does not match the output expected
[英]Java Date output is wrong. Why?
我在玩Java Date,無法理解:
Date myBirth = new Date(1991,01,21);
Log.d("DATE: ", "" + myBirth);
在這里,我初始化了Date對象。 為什么得到此輸出?
DEBUG/DATE:(31693): Sat Feb 21 00:00:00 EET 3891
從日期文檔 :
- 年y由整數y-1900表示。
- 一個月由0到11之間的整數表示; 0是一月,1是二月,依此類推; 因此11月是12月。
從Javadoc中引用以下不推薦使用的Date構造函數:
Parameters:
year - the year **minus 1900**.
month - the month between 0-11.
date - the day of the month between 1-31.
所以輸出就是您要的,而不是您想要的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.