1-1-8-11 请问:在JAVA中怎样得到系统时间?
发信人: sld (光明导师), 信区: Java标题: Re: 请问:在JAVA中怎样得到系统时间?
发信站: BBS 水木清华站 (Fri Sep 13 19:05:10 2002), 站内信件
年是从1900年开始的,月则是1月为0,这和C的tm结构的定义是一致的
【 在 Stroot (望江南) 的大作中提到: 】
: import java.util.*;
: class StringTest{
: public static void main(String[] args){
: // get the supported ids for GMT+08:00 (Beijing Time)
: String[] ids = TimeZone.getAvailableIDs(+8 * 60 * 60 * 1000);
: SimpleTimeZone pdt = new SimpleTimeZone(+8 * 60 * 60 * 1000, ids);
: Calendar calendar = new GregorianCalendar(pdt);
: int y = calendar.getTime().getYear();
: int m = calendar.getTime().getMonth();
: int d = calendar.getTime().getDate();
: System.out.println("Current Time is:" + y + "年"+m+"月"+d+"日");
页:
[1]