帮忙!
import java.util.*;
import java.text.*;
public class Abc
{
public static void main()
{
long DAY = 24L * 60L * 60L * 1000L;
SimpleDateFormat df = new SimpleDateFormat( "MM.dd.yyyy" );
Date d1 = df.parse( "04.30.2001" )throws ParseException;
Date d2 = df.parse( "05.01.2001" )throws ParseException;
System.out.println( "The number days between:" );
System.out.println( d1 );
System.out.println( "and:" );
System.out.println( d2 );
System.out.println( "is: " + (( d2.getTime() - d1.getTime() ) / DAY ));
}
}
运行不了,帮助!
[解决办法]
1,main方法有错;
2,异常捕获有问题;
import java.util.*;
import java.text.*;
public class Abc
{
public static void main(String args[]) throws Exception
{
long DAY = 24L * 60L * 60L * 1000L;
SimpleDateFormat df = new SimpleDateFormat( "MM.dd.yyyy" );
Date d1 = df.parse( "04.30.2001" );
Date d2 = df.parse( "05.01.2001" );
System.out.println( "The number days between:" );
System.out.println( d1 );
System.out.println( "and:" );
System.out.println( d2 );
System.out.println( "is: " + (( d2.getTime() - d1.getTime() ) / DAY ));
}
}
[解决办法]