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?
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd,hh,mm,ss");
String dateValue=sdf.format(curDate.getTime());
System.out.println(dateValue);根据得到的dateValue中的hh,判断大与12?
* 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;这个是人家定义的常量而已拉,受不了
static int AM_PM(Field number for get and set indicating whether the HOUR is before or after noon.)应该用curDate.AM或者curDate.AM_PM吧?
System.out.println(rightNow.PM);
帮你看了一下类库!这个可以!
{
public static void main(String args[])
{
GregorianCalendar ca = new GregorianCalendar();
System.out.println(ca.get(GregorianCalendar.AM_PM));
}
}
结果为“0”是上午 结果为“1”是下午