GregorianCalendar curDate=new GregorianCalendar();
    
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd,hh,mm,ss");
String dateValue=sdf.format(curDate.getTime());
    System.out.println(dateValue);根据得到的dateValue中的hh,判断大与12?

解决方案 »

  1.   

    你不要学习java了,你根本就不适合做程序员的 /**
         * Value of the <code>AM_PM</code> field indicating the
         * period of the day from noon to just before midnight.
         */
        public final static int PM = 1;这个是人家定义的常量而已拉,受不了
      

  2.   

    curDate.get(GregorianCalendar.AM_PM) == GregorianCalendar.PM
      

  3.   

    public int get(int field);curDate.get(Calendar.AM_PM)
      

  4.   

    static int AM(Value of the AM_PM field indicating the period of the day from midnight to just before noon.) 
    static int AM_PM(Field number for get and set indicating whether the HOUR is before or after noon.)应该用curDate.AM或者curDate.AM_PM吧? 
      

  5.   

    Calendar rightNow = Calendar.getInstance();    System.out.println(rightNow.AM);
        System.out.println(rightNow.PM);
    帮你看了一下类库!这个可以!
      

  6.   

    import java.util.GregorianCalendar;public class GregorianTest
    {
       public static void main(String args[])
       {
        GregorianCalendar ca = new GregorianCalendar();
        System.out.println(ca.get(GregorianCalendar.AM_PM));
       } 
    }
    结果为“0”是上午     结果为“1”是下午