Package java.util

Examples of java.util.Calendar$CalendarAccessControlContext


   * @param month
   * @return
   */
  public static int[] statCalendarLogs(SiteBean site, SessionUserObject user, Calendar month)
  {
    Calendar firstDate = (Calendar)month.clone();
    firstDate.set(Calendar.DATE,1);
    DateUtils.resetTime(firstDate);
    Calendar nextMonthFirstDate = (Calendar)firstDate.clone();
    nextMonthFirstDate.add(Calendar.MONTH,1);
   
    //����ָ���·��ж�����
    Calendar tempCal = (Calendar)nextMonthFirstDate.clone();
    tempCal.add(Calendar.DATE,-1);
    int dateCount = tempCal.get(Calendar.DATE);     
    int[] logCounts = new int[dateCount+1];
   
    //��ѯ�����µ������ռǽ���ͳ��

    StringBuffer hql = new StringBuffer("SELECT j.writeTime FROM DiaryBean AS j WHERE j.writeTime>=:beginTime AND j.writeTime<:endTime AND j.status=:status AND j.site.id=:site");
    if(!site.isOwner(user)){
      //�ų��û�û��Ȩ�޷��ʵķ���
      hql.append(" AND (j.catalog.type<>:cat_type");
      if(user != null)
        hql.append(" OR (j.catalog.type=:cat_type AND j.catalog.id IN (SELECT p.key.catalog FROM CatalogPermBean AS p WHERE p.key.user=:user))");
      hql.append(')');
    }
   
    Session ssn = getSession();
   
    try{
      Query q = ssn.createQuery(hql.toString()).setCacheable(true);
      q.setTimestamp("beginTime", firstDate.getTime());
      q.setTimestamp("endTime", nextMonthFirstDate.getTime());
      q.setInteger("status", DiaryBean.STATUS_NORMAL);
      q.setInteger("site", site.getId());
      if(!site.isOwner(user)){
        q.setInteger("cat_type", CatalogBean.TYPE_OWNER);
        if(user != null)
          q.setInteger("user", user.getId());
      }
      int total = 0;
      Iterator logs = q.list().iterator();
      while(logs.hasNext()){
        tempCal.setTime((Date)logs.next());
        int date = tempCal.get(Calendar.DATE);
        logCounts[date]++;
        total ++;
      }
     
      logCounts[0] = total; 
View Full Code Here


   * @param year
   * @param month
   * @return
   */
  public int[][] calendar(int year, int month) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.YEAR, year);
    cal.set(Calendar.MONTH, month - 1);
    cal.set(Calendar.DAY_OF_MONTH, 1);
    int firstDateInWeek = cal.get(Calendar.DAY_OF_WEEK) - 1;
    int dateOfMonth = getMonthDateCount(cal);
    int base = dateOfMonth + firstDateInWeek;
    int row = base / 7;
    row += ((base % 7) > 0) ? 1 : 0;
    int[][] cals = new int[row][7];
View Full Code Here

   *
   * @param cal
   * @return
   */
  private static int getMonthDateCount(Calendar cal) {
    Calendar cal2 = (Calendar) cal.clone();
    cal2.add(Calendar.MONTH, 1);
    cal2.set(Calendar.DAY_OF_MONTH, 1);
    cal2.add(Calendar.DAY_OF_MONTH, -1);
    return cal2.get(Calendar.DAY_OF_MONTH);
  }
View Full Code Here

   *
   * @param field
   * @return
   */
  public int calendar(int field) {
    Calendar cal = Calendar.getInstance();
    String param;
    int defValue;
    switch (field) {
    case 1:
      param = "year";
      defValue = cal.get(Calendar.YEAR);
      break;
    case 2:
      param = "month";
      defValue = cal.get(Calendar.MONTH) + 1;
      break;
    case 3:
      param = "date";
      defValue = cal.get(Calendar.DATE);
      break;
    default:
      return -1;
    }
    return RequestUtils.getParam(request, param, defValue);
View Full Code Here

  public Program getProgram(String uniqueID) {
    String[] id = uniqueID.split("_");
    Date progDate;
    try {
      java.util.Date date = new SimpleDateFormat(MutableProgram.ID_DATE_FORMAT).parse(id[4]);
      Calendar cal = Calendar.getInstance();
      cal.setTimeInMillis(date.getTime());
      progDate = new Date(cal);
    } catch (ParseException e) {
      mLog.severe("Couldn't parse date from unique ID");
      return null;
    }
View Full Code Here

    centerPanel.add(content, BorderLayout.NORTH);
    return centerPanel;
  }

  public Date setTimeToDate(int minutes) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, minutes / 60);
    cal.set(Calendar.MINUTE, minutes % 60);
    return cal.getTime();
  }
View Full Code Here

    cal.set(Calendar.MINUTE, minutes % 60);
    return cal.getTime();
  }

  public int getTimeFromDate(Date time) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(time);
    return cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
  }
View Full Code Here

  }

  public void setBirth(Date birth) {
    this.birth = birth;
    if(birth!=null){
      Calendar cal = Calendar.getInstance();
      int cur_year = cal.get(Calendar.YEAR);
      cal.setTime(birth);
      int the_year = cal.get(Calendar.YEAR);
      age = cur_year - the_year;
    }
    else
      age = -1;
  }
View Full Code Here

   
    toSet.setValue(cal.getTime());
  }
 
  private int getTimeInMinutes(JSpinner toGet) {
    Calendar cal = Calendar.getInstance();
    cal.setTime((java.util.Date)toGet.getValue());
   
    return cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
  }
View Full Code Here

  public void doLayout() {
    super.doLayout();
    // scroll to current time when the main frame is switched visible
    if (!initialScrollingDone) {
      initialScrollingDone = true;
      Calendar cal = Calendar.getInstance();
      int hour = cal.get(Calendar.HOUR_OF_DAY);
      scrollToTime(hour * 60);
      updateScrollBars();
    }
  }
View Full Code Here

TOP

Related Classes of java.util.Calendar$CalendarAccessControlContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.