想得到当前系统的日期,要求是字符格式(YYYYMMDD),必须是八位,也就是20060916的格式
再得当前系统的时间,要求是字符格式(HH:MM:SS)

解决方案 »

  1.   

    到JAVA API 文档资料查这个类的用法:SimpleDateFormat
    即可找到你想要的答案
      

  2.   

    获取时间的格式,需要用到一个专门用于时间格式的类java.text.SimpleDateFormat。 
    首先,定义一个SimpleDateFormat变量 
    SimpleDateFormat sdf_date = new SimpleDateFormat("",Locale.SIMPLIFIED_CHINESE); 
    SimpleDateFormat sdf_time = new SimpleDateFormat("",Locale.SIMPLIFIED_CHINESE); 
    sdf_date.applyPattern("yyyyMMdd"); 
    sdf_time.applyPattern("HH:mm:ss"); 
    String dateStr = sdf_date.format(new Date());  
    String timeStr = sdf_time.format(new Date()); 
    dateStr timeStr就是你想要的值!