import java.text.SimpleDateFormat;
import java.util.Date;
public class DateFormatDemo{
public static void main(String[] args){
String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
System.out.println(str3);
//当前系统时间2017--03--26
String datess=sdf1.format(System.currentTimeMillis());
System.err.println("当前系统时间"+datess);
}
import java.util.Date;
public class DateFormatDemo{
public static void main(String[] args){
String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
System.out.println(date);
Date date = new Date();//定义时间对象
SimpleDateFormat sdf1=new SimpleDateFormat("yyyy--MM--dd"); //创建个时间字符串
String str1=sdf1.format(date);//获取时间对象的字符串
System.out.println(str1);//打印时间
//2017年3月26日 星期日 上午12时38分53秒
SimpleDateFormat sdf2=(SimpleDateFormat) SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.FULL, SimpleDateFormat.LONG);
String str2=sdf2.format(date);//获取时间对象的字符串
System.out.println(str2);//打印时间
//2017年3月26日 星期日
SimpleDateFormat sdf3=(SimpleDateFormat) SimpleDateFormat.getDateInstance(SimpleDateFormat.FULL);
String str3=sdf3.format(date);
System.out.println(str3);
//当前系统时间2017--03--26
String datess=sdf1.format(System.currentTimeMillis());
System.err.println("当前系统时间"+datess);
}