获取当前的年月,例如200804

解决方案 »

  1.   

    JAVA交流与学习群:45609427  
    挑战技术,超越自我!!
      

  2.   

    new Date()
    或者
    new Calendar()
      

  3.   

    String date = new SimpleDateFormat("MM,dd,yyyy",
        Locale.SIMPLIFIED_CHINESE).format(new java.util.Date());
      

  4.   

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss");
    注意在后面,输出的格式可以自己控制
      

  5.   

    刚学java,有些东西不太懂,请大家帮忙解决
      

  6.   

    package common;import java.text.SimpleDateFormat;
    import java.util.Date;/**
     * @author zhang_wj
     *
     */
    public class DateControl {
    /*
     * 输出YYYY-MM-DD
     */
    public static String getStringYearMonthDate(){ Date currentTime = new Date();
    SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-dd");
    String dateString = formatter.format(currentTime);
    return dateString; }
    public static void main(String[] args)throws Exception{

    DateControl datecontorl = new DateControl();
    System.out.println(datecontorl.getStringYearMonthDate());
    }
    }
      

  7.   


    public class test {
    public static void main(String[] args) {
    SimpleDateFormat sdf=new SimpleDateFormat("yyyyMM");
    String date = sdf.format(new Date());
    System.out.println(date);
            }
    }
      

  8.   

    我没有看清,你要要求,不好意思。
    public static String getStringYearMonthDate2(){ Date currentTime = new Date();
    SimpleDateFormat formatter = new SimpleDateFormat ("yyyyMMdd");
    String dateString = formatter.format(currentTime);
    return dateString; }