据说,java 基础类中有一个叫Calendar 的东东……

解决方案 »

  1.   

    如果你需要 [email protected] 联系
      

  2.   

    获得当天的DATE日期
    Calendar.getInstance().get(Calendar.DAY_OF_MONTH)今天是星期几 
    Calendar.getInstance().get(Calendar.DAY_OF_WEEK)然后自己判断  后面没问题了吧~! 接分
      

  3.   

    上月最后一天用本月第一天-1天即可Calendar的时间类型加减功能特别强大, 好好看看
      

  4.   

    Calendar.getInstance().get(int filed)..自己去设置........接分
      

  5.   

    /**
         * Get the date of monday in this week
         * 
         * @return yyyy-MM-dd
         */
        public static String getMondayOfThisWeek() {
            String strTemp = "";
            Calendar c = Calendar.getInstance();
            int dayofweek = c.get(Calendar.DAY_OF_WEEK) - 1;
            if (dayofweek == 0)
                dayofweek = 7;
            c.add(Calendar.DATE, -dayofweek + 1);
            strTemp = c.get(1) + "-";
            if (c.get(2) + 1 < 10)
                strTemp += "0";
            strTemp = strTemp + (c.get(2) + 1) + "-";
            if (c.get(5) < 10)
                strTemp += "0";
            strTemp += c.get(5);
            return strTemp;
        }    /**
         * Get the date of sunday in this week
         * 
         * @return yyyy-MM-dd
         */
        public static String getSundayOfThisWeek() {
            String strTemp = "";
            Calendar c = Calendar.getInstance();
            int dayofweek = c.get(Calendar.DAY_OF_WEEK) - 1;
            if (dayofweek == 0)
                dayofweek = 7;
            c.add(Calendar.DATE, -dayofweek + 7);
            strTemp = c.get(1) + "-";
            if (c.get(2) + 1 < 10)
                strTemp += "0";
            strTemp = strTemp + (c.get(2) + 1) + "-";
            if (c.get(5) < 10)
                strTemp += "0";
            strTemp += c.get(5);
            return strTemp;
        }
      

  6.   

    /**
     * Get the date of monday in this week
     * 
     * @return yyyy-MM-dd
     */
    public static String getMondayOfThisWeek() {
    Calendar c = Calendar.getInstance();
    int dayofweek = c.get(Calendar.DAY_OF_WEEK) - 1;
    if (dayofweek == 0)
    dayofweek = 7;
    c.add(Calendar.DATE, -dayofweek + 1);
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
    return sdf.format(c.getTime());
    } /**
     * Get the date of sunday in this week
     * 
     * @return yyyy-MM-dd
     */
    public static String getSundayOfThisWeek() {
    Calendar c = Calendar.getInstance();
    int dayofweek = c.get(Calendar.DAY_OF_WEEK) - 1;
    if (dayofweek == 0)
    dayofweek = 7;
    c.add(Calendar.DATE, -dayofweek + 7);
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
    return sdf.format(c.getTime());
    }
      

  7.   

    Calendar.getInstance().get(Calendar.DAY_OF_MONTH)//get Date
    Calendar.getInstance().get(Calendar.DAY_OF_WEEK)//get week