日期:2014-05-20 浏览次数:20650 次
import java.text.*; import java.util.*; public class Test79 { public static void main(String[] args) { // TODO Auto-generated method stub SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar = Calendar.getInstance();// 获取当前时间为更新时间 Date updateDate = calendar.getTime(); System.out.println(sdf.format(updateDate)); String saleTime = "1980-7-1"; Date saleTime1 = null; try { saleTime1 = new SimpleDateFormat("yyyy-MM-dd").parse(saleTime); System.out.println(saleTime1); } catch (ParseException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }
------解决方案--------------------
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date date = new Date();
String strdate = sdf.format(date);
------解决方案--------------------
这我怎么没学过呢..??~~55555555