Topic: 怎么取得当前日期的年月日? |
Print this page |
1.怎么取得当前日期的年月日? | Copy to clipboard |
Posted by: dwju Posted on: 2003-08-11 15:43 我想单独取得当前日期的年月日,请问用什么方法? 最好能贴点代码出来参考以下,多谢! |
2.Re:怎么取得当前日期的年月日? [Re: dwju] | Copy to clipboard |
Posted by: fly2fire Posted on: 2003-08-11 16:28 查查java的帮助不就知道了.提示.查Calendar |
3.Re:怎么取得当前日期的年月日? [Re: dwju] | Copy to clipboard |
Posted by: toString Posted on: 2003-08-11 20:27 import java.util.Date; public class test { public static void main(String[] args){ Date date = new Date(); int year=date.getYear()+1900; int month=date.getMonth()+1; int day=date.getDate(); System.out.println("It is "+year+"/"+month+"/"+day+" (YYYY/MM/DD)today."); } } |
4.Re:怎么取得当前日期的年月日? [Re: toString] | Copy to clipboard |
Posted by: 不懂 Posted on: 2003-08-12 00:52 toString wrote: 请问代码中的年为何要+1900 月为何要+1 呢?日为什么不用加?? 请指教!! |
5.Re:怎么取得当前日期的年月日? [Re: 不懂] | Copy to clipboard |
Posted by: nothing Posted on: 2003-08-12 07:23 import java.util.*; |
6.Re:怎么取得当前日期的年月日? [Re: 不懂] | Copy to clipboard |
Posted by: why Posted on: 2003-08-12 08:27 不懂 wrote: http://java.sun.com/j2se/1.4.1/docs/api/java/util/Date.html getYear() Deprecated. As of JDK version 1.1, replaced by Calendar.get(Calendar.YEAR) - 1900. getMonth() Deprecated. As of JDK version 1.1, replaced by Calendar.get(Calendar.MONTH). Returns a number representing the month that contains or begins with the instant in time represented by this Date object. The value returned is between 0 and 11, with the value 0 representing January. These methods are deprecated, use java.util.Calendar instead: http://java.sun.com/j2se/1.4.1/docs/api/java/util/Calendar.html |
7.Re:怎么取得当前日期的年月日? [Re: dwju] | Copy to clipboard |
Posted by: dwju Posted on: 2003-08-12 16:24 多谢,那会急了,没搞出来,让各位老大费心了,已经解决!再次感谢! |
8.Re:怎么取得当前日期的年月日? [Re: dwju] | Copy to clipboard |
Posted by: zgd Posted on: 2003-08-13 23:01 getYear() |
9.Re:怎么取得当前日期的年月日? [Re: why] | Copy to clipboard |
Posted by: 不懂 Posted on: 2003-08-14 15:56 why wrote: 谢谢指教!! |
10.Re:怎么取得当前日期的年月日? [Re: dwju] | Copy to clipboard |
Posted by: kevnlin Posted on: 2003-08-15 11:37 new time() |
11.Re:怎么取得当前日期的年月日? [Re: dwju] | Copy to clipboard |
Posted by: aquila Posted on: 2003-08-15 14:59 自己有机会的时候多看看jdk的帮助,很有用处的,呵呵,jdk的帮助里面都有了。 |
12.Re:怎么取得当前日期的年月日? [Re: dwju] | Copy to clipboard |
Posted by: fat32 Posted on: 2003-08-17 15:03 http://www.javaalmanac.com/egs/java.util/GetCurDate.html |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |