Package java.util

Examples of java.util.Calendar


   * @param ext  ����: .gif
   * @return
   * @throws IOException
   */
  private String[] createNewPhotoURI(HttpContext ctx, String ext) throws IOException{
    Calendar cal = Calendar.getInstance();
    StringBuffer dir = new StringBuffer();
    dir.append(getUploadPath(ctx));
    dir.append(cal.get(Calendar.YEAR));
    dir.append(File.separator);
    dir.append(cal.get(Calendar.MONTH)+1);
    dir.append(File.separator);
    dir.append(cal.get(Calendar.DATE));
    dir.append(File.separator);
    File file = new File(dir.toString());
    if(!file.exists()){
      //���Ŀ¼�������򴴽�Ŀ¼
      synchronized(FileSystemSaver.class){
View Full Code Here


    boolean write_db = false;
    Cookie u_cookie = RequestUtils.getCookie(request, KEY_COOKIE);
    String ident = getSiteIdAsString(site);
    if(u_cookie == null){
      //����Cookie��Ч�ڵ��������
      Calendar t = Calendar.getInstance();
      t.add(Calendar.DATE, 1);
      DateUtils.resetTime(t);
      int maxAge = (int)(t.getTime().getTime()-System.currentTimeMillis()) / 1000;
      RequestUtils.setCookie(request, response, KEY_COOKIE, ident, maxAge);
      write_db = true;
    }
    else{
      String cookie_value = u_cookie.getValue();
      if(cookie_value.indexOf(ident)<0){
        //����Cookie��Ч�ڵ��������
        Calendar t = Calendar.getInstance();
        t.add(Calendar.DATE, 1);
        DateUtils.resetTime(t);
        int maxAge = (int)(t.getTime().getTime()-System.currentTimeMillis()) / 1000;
        //����Cookie
        RequestUtils.setCookie(request, response, KEY_COOKIE, cookie_value+ident, maxAge);
        write_db = true;
      }
    }
View Full Code Here

   * @return ��������еĵ�һ��Ԫ���Ǹ��µ��ռ�������,�����Ƕ�Ӧÿ����ռ���
   */
  public List diary_counts_by_month(SiteBean site, SessionUserObject user, int year, int month){
    if(site==null)
      return null;
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.YEAR, year);
    cal.set(Calendar.MONTH, month-1);
    int[] logc = DiaryDAO.statCalendarLogs(site, user, cal);
    List logcs = new ArrayList();
    for(int i=0;i<logc.length;i++){
      logcs.add(new Integer(logc[i]));
    }
View Full Code Here

      return d;
    }
   
    private void correctValues(Date d) {
      if(mMeSpinner != null && mStartOfDayTimeSp != null && mEndOfDayTimeSp != null) {
        Calendar cal = Calendar.getInstance();
        int endTime, startTime;
       
        if(mMeSpinner.equals(mStartOfDayTimeSp)) {
          cal.setTime((Date)mEndOfDayTimeSp.getValue());
          endTime = cal.get(Calendar.HOUR_OF_DAY) * 60
              + cal.get(Calendar.MINUTE);
         
          cal.setTime(d);
          startTime = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
         
          if(endTime - startTime < -1) {
            mEndOfDayTimeSp.setValue(d);
          }
        }
        else {
          cal.setTime(d);
          endTime = cal.get(Calendar.HOUR_OF_DAY) * 60
              + cal.get(Calendar.MINUTE);
         
          cal.setTime((Date)mStartOfDayTimeSp.getValue());
          startTime = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
         
          if(endTime - startTime < -1) {
            mStartOfDayTimeSp.setValue(d);
          }
        }
View Full Code Here

            log.debug("Existing modtime on existing file: " + remoteTextFile);
            Date modTime = ftp.modtime(remoteTextFile);
            log.debug(remoteTextFile + ": " + modTime.toString());
   
            // set modtime
            Calendar cal = Calendar.getInstance();
            cal.setTime(modTime);
            cal.add(Calendar.DAY_OF_YEAR, 1);
            cal.add(Calendar.HOUR_OF_DAY, 2);
            cal.add(Calendar.MINUTE, 3);
            cal.add(Calendar.SECOND, 4);
            Date desiredModTime = cal.getTime();
            log.debug("Setting mod-time to " + desiredModTime.toString());
            ftp.setModTime(remoteTextFile, desiredModTime);
           
            Date actualModTime = ftp.modtime(remoteTextFile);
            log.debug(remoteTextFile + ": " + actualModTime.toString());
View Full Code Here

        Date lastModified = null;
        if (formatIndex >= formats.length) {
            log.warn("Exhausted formats - failed to parse date");
            return null;
        }
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, 2);
       
        int prevIndex = formatIndex;
        for (int i = formatIndex; i < formats.length; i++, formatIndex++) {
            for (int j = 0; j < formats[i].length; j++) {
                try {
                    SimpleDateFormat dateFormatter = new SimpleDateFormat(formats[formatIndex][j], locale);
                    lastModified = dateFormatter.parse(lastModifiedStr);
                    if (lastModified.after(cal.getTime())) {
                        log.debug("Swapping to alternate format (found date in future)");
                        continue;
                    }
                    else // all ok, exit loop
                        return lastModified;
View Full Code Here

    mProgramTableScrollPane.requestFocusInWindow();
  }

  public void scrollToNow() {
    mProgramTableScrollPane.resetScrolledTime();
    Calendar cal = Calendar.getInstance();
    int hour = cal.get(Calendar.HOUR_OF_DAY);
    devplugin.Date day = new devplugin.Date();
    scrollTo(day, hour * 60 + cal.get(Calendar.MINUTE));
    mProgramTableScrollPane.requestFocusInWindow();
  }
View Full Code Here

    pack();
    Settings.layoutWindow("channelConfig", this, new Dimension(420,350));
  }
 
  private void setTimeDate(JSpinner toSet, int time) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, time / 60);
    cal.set(Calendar.MINUTE, time % 60);
   
    toSet.setValue(cal.getTime());
  }
View Full Code Here

   * Ensures that the field is valid date
   */
  public ActionErrors checkForDate(String fieldLabel, String yearValue, String monthValue,
      String dayValue, String errorKey, ActionErrors actionErrors)
  {
    Calendar calendar = Calendar.getInstance();
    calendar.setLenient(false);
    try {
      calendar.set(Integer.parseInt(yearValue), Integer.parseInt(monthValue), Integer.parseInt(dayValue));
    } catch (Exception e) {
      ActionMessage error = new ActionMessage(errorKey, messages.getMessage(fieldLabel));
      actionErrors.add(errorKey, error);
    }
    return actionErrors;
View Full Code Here

   * @param locale the locale.
   * @return
   */
  public ActionErrors validateDateString(String fieldLabel, String date, Locale locale, String errorKey, ActionErrors actionErrors)
  {
    Calendar calendar = new GregorianCalendar();
    calendar.setLenient(false);
    DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
    try {
      Date parsedDate = df.parse(date);
      calendar.setTime(parsedDate);
    } catch (ParseException e) {
      ActionMessage error = new ActionMessage(errorKey, messages.getMessage(fieldLabel));
      actionErrors.add(errorKey, error);
    } catch (Exception e) {
      ActionMessage error = new ActionMessage(errorKey, messages.getMessage(fieldLabel));
View Full Code Here

TOP

Related Classes of java.util.Calendar

Copyright © 2015 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.