从今天到2008年8月8日有多少天.拿{JAVA}怎么写程序

来源:百度知道 编辑:UC知道 时间:2024/05/22 14:52:53
刚学JAVA不久.不要用太深的语句.还没学呢.这样老师会减分的
The opening ceremony of 2008 Olympic game is to be held in Beijing at 2008-08-08 08:00 pm. Please write a program that takes advantage of the GregorianCalendar class to back count the days to the opening ceremony. You are required to write a class named BeijingOlympicCalendar . The class should have the following methods: 这是题目.老师给的提示说要用减法.
OlymplicCalendarTest.java:3:类CalendarTest是公共的,应在名为CalendarTest.java的文件中声明
public class CalendarTest
错误

怎么改?没法运行啊

Calendar olympicDate = Calendar.getInstance();
olympicDate.set(2008,7,8);//月是从0开始计算的
long olympicSeconds = olympicDate.getTimeInMillis();

Calendar currentDate = Calendar.getInstance();
long currentSeconds = currentDate.getTimeInMillis();

//2个时间相差的秒数
long value = olympicSeconds - currentSeconds;
//2个时间相差的天数
long day = value/(60*60*24);

谢谢你啊.
虽然我不是提问的.但是我也十分感谢你