如题,用yyyy-MM-dd能得出正确的结果,但是用yyyy-MM-DD得到的是什么呢?

解决方案 »

  1.   

    yyyy-MM-dd和yyyy-mm-dd就有区别
    一个MM是月,一个MM是秒
      

  2.   

    yyyy-MM-dd得到月中的天数yyyy-MM-DD得到年中的天数
      

  3.   

    晕,我问的是yyyy-MM-dd跟yyyy-MM-DD的区别,区别肯定是有的,因为我得到了不同的结果
      

  4.   

    SQL> select to_char(sysdate,'yyyy-MM-DD') from dual;TO_CHAR(SY
    ----------
    2007-03-15SQL> select to_char(sysdate,'yyyy-MM-dd') from dual;TO_CHAR(SY
    ----------
    2007-03-15有什么区别???
      

  5.   

    D   Day in year
    d   Day in month
      

  6.   

    字母  日期或时间元素  表示  示例  
    G  Era 标志符  Text  AD  
    y  年  Year  1996; 96  
    M  年中的月份  Month  July; Jul; 07  
    w  年中的周数  Number  27  
    W  月份中的周数  Number  2  
    D  年中的天数  Number  189  
    d  月份中的天数  Number  10  
    F  月份中的星期  Number  2  
    E  星期中的天数  Text  Tuesday; Tue  
    a  Am/pm 标记  Text  PM  
    H  一天中的小时数(0-23)  Number  0  
    k  一天中的小时数(1-24)  Number  24  
    K  am/pm 中的小时数(0-11)  Number  0  
    h  am/pm 中的小时数(1-12)  Number  12  
    m  小时中的分钟数  Number  30  
    s  分钟中的秒数  Number  55  
    S  毫秒数  Number  978  
    z  时区  General time zone  Pacific Standard Time; PST; GMT-08:00  
    Z  时区  RFC 822 time zone  -0800  
      

  7.   

    SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月DD日");//2007年03月74日
    SimpleDateFormat sdff=new SimpleDateFormat("yyyy年MM月dd日");//2007年03月15日当前时间格式化后
      

  8.   

    汗~
    由于一直用的是oracle本身的日期格式化功能
    反而倒不知道java的日期格式化了~~
    鄙视一下自己~
      

  9.   

    import java.util.Date;
    public class test_11 { /**
     * @param args
     */
    public static void main(String[] args) {
      /*
     String s = "2007-03-16";
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
     try {
    Date date=sdf.parse(s);
    SimpleDateFormat sdf1=new SimpleDateFormat("yyy-MM-dd 08:00:00");
    System.out.println(sdf1.format(date));
    Long l=date.getTime();
    Long l_1=l-24*60*60*1000L;
    System.out.println(sdf1.format(l_1));
    } catch (ParseException e) {
    e.printStackTrace();
    }
           */
     String s = "2007-03-16";
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
     String s = "2007-03-16";
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         try {
    Date date=sdf.parse(s);
    SimpleDateFormat sdf0 = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-DD");
    System.out.println("yyyy-MM-dd:"+sdf0.format(date));
    System.out.println("yyyy-MM-DD:"+sdf1.format(date));
    } catch (ParseException e) {
    e.printStackTrace();
    }    
    }}
    结果:
    yyyy-MM-dd:2007-03-16
    yyyy-MM-DD:2007-03-75
    结论:
    dd得到月中的天数
    DD得到年中的天数