import java.util.*;
import java.text.*;
class Showtime
{
public static void main(String[] args)
{
Date d=new Date();
Date d2=new Date();
SimpleDateFormat f= new SimpleDateFormat ("yyyy.MM.dd");
String dateString = f.format(d);
System.out.println(d);
System.out.println(dateString);
dateString="1982.05.19";
// ParsePosition pos = new ParsePosition(0);
//如不捕获异常,添加上句注释语句d2一句改为d2=f.parse(dateString,pos)
try{
d2 = f.parse(dateString);
System.out.println(d2);
}catch(Exception ex){}
}
}
import java.text.*;
class Showtime
{
public static void main(String[] args)
{
Date d=new Date();
Date d2=new Date();
SimpleDateFormat f= new SimpleDateFormat ("yyyy.MM.dd");
String dateString = f.format(d);
System.out.println(d);
System.out.println(dateString);
dateString="1982.05.19";
// ParsePosition pos = new ParsePosition(0);
//如不捕获异常,添加上句注释语句d2一句改为d2=f.parse(dateString,pos)
try{
d2 = f.parse(dateString);
System.out.println(d2);
}catch(Exception ex){}
}
}