因为,在calendar中,MONTH常量是从0~11的,所以要加1啊

解决方案 »

  1.   

    import java.io.*;
    import java.text.ParseException;
    import java.util.Locale;
    import java.util.TimeZone;
    import java.util.Date;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;public class SLDate
        implements Serializable, Cloneable
    {
        private GregorianCalendar m_objCal;
        private static Calendar utcCal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
        private static DateFormat m_objFormatter;
        private static DateFormat m_objgmtformatter;
        private static TimeZone m_objcachedDefaultZone = TimeZone.getDefault();    static
        {
            m_objFormatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
            m_objgmtformatter = new SimpleDateFormat("d MMM yyyy HH:mm:ss 'GMT'", Locale.US);
            m_objgmtformatter.setTimeZone(TimeZone.getTimeZone("Africa/Casablanca"));
        }
    public SLDate(int nYear, int nMonth, int nDay, int nHour, int nMinute)
        {
            this(nYear, nMonth, nDay, nHour, nMinute, 0);
        }
    我用这种方法计算出来的日期,在跨月的时候总是出错,比如9月份会算出9月31日,10月份只算出30天
    请问大家为什么?
      

  2.   

    1-12月分别用0-11表示
    是不是java没有考虑到?总觉得是个失误
      

  3.   

    Day是怎么表示的?
    是不是1-31日分别用0-30表示?
    谢谢大家。