J2ME中处理日期相关问题[2]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

    protected void destroyApp(boolean arg0) throws MIDletStateChangeException
    {
    
    }
   
    public void commandAction(Command cmd,Displayable disp)
    {
        if(cmd == okCmd)
        {
            Date date = dateField.getDate();
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            mainForm.append(getDetailInfo(calendar));
        }
    }
   
    private String getDetailInfo(Calendar calendar)
    {
        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH)+1;
        int day = calendar.get(Calendar.DAY_OF_MONTH);
        int hour = calendar.get(Calendar.HOUR);
        int min = calendar.get(Calendar.MINUTE);
        int sec = calendar.get(Calendar.SECOND);
        return ""+year+"年"+month+"月"+day+"日"+hour+"时"+min+"分"+sec+"秒";
    }

本文关键:J2ME中处理日期相关问题
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top