Package java.text

Examples of java.text.DateFormat$DateFormatGetter


      // This value will display the selected month in the mini calendar.
      GregorianCalendar selectedDate = new GregorianCalendar(year.intValue(), month.intValue() - 1, 1);
      dateForm.set("selectedDate", selectedDate);
      request.setAttribute("selectedDate", selectedDate);

      DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
      // simple mode basicall is non-calendar/activities mode, because
      // the following behaviour is unexpected in sales.
      boolean simpleMode = ((Boolean)dateForm.get("simpleMode")).booleanValue();
      String startDate = (String) dateForm.get("startDate");
      String endDate = (String) dateForm.get("endDate");
      if (!simpleMode) {
        if ((startDate == null || startDate.length() < 1) && (endDate == null || endDate.length() < 1)) {
          // if startDate *AND* endDate are not already set, then
          // set them both to the current date in the format MM/dd/yyyy
          startDate = df.format(currentDate.getTime());
          endDate = startDate;
        }
      }
      dateForm.set("startDate", startDate);
      dateForm.set("endDate", endDate);

      // if startTime is given, but endTime is NOT, then set the
      // endTime = startTime + 1 hour
      String startTime = (String) dateForm.get("startTime");
      String endTime = (String) dateForm.get("endTime");
      if ((startTime != null && startTime.length() > 0) && (endTime == null || endTime.length() <= 0)) {
        DateFormat tf = DateFormat.getTimeInstance(DateFormat.SHORT, locale);
        GregorianCalendar endTimeCal = new GregorianCalendar();
        // get a Calendar object generated from the given startTime String
        endTimeCal.setTime(tf.parse(startTime));
        // add one hour to the Calendar object
        endTimeCal.set(GregorianCalendar.HOUR_OF_DAY, endTimeCal.get(GregorianCalendar.HOUR_OF_DAY) + 1);
        // get the String representation of the Calendar object, using the
        // SimpleDateFormat
        String defaultEndTime = tf.format(endTimeCal.getTime());
        // set the new endTime String to the form
        dateForm.set("endTime", defaultEndTime);
      }
    } catch (Exception e) {
      logger.error("[execute]: Exception", e);
View Full Code Here


      Calendar calendarStart = Calendar.getInstance();
      calendarStart.setTime(tvo.getStart());

      int startHrs = calendarStart.get(Calendar.HOUR_OF_DAY);
      int startMins = calendarStart.get(Calendar.MINUTE);
      DateFormat df = new SimpleDateFormat("h:mm a");

      tsForm.setStartTime((df.format(tvo.getStart())).toString());

      Calendar calendarEnd = Calendar.getInstance();
      calendarEnd.setTime(tvo.getEnd());

      int endHrs = calendarEnd.get(Calendar.HOUR_OF_DAY);
      int endMins = calendarEnd.get(Calendar.MINUTE);
      tsForm.setEndTime((df.format(tvo.getEnd())).toString());

      Float BreakTime = new Float(tvo.getBreakTime());
      int iHours = BreakTime.intValue();
      float breakTime = (BreakTime.floatValue() - iHours) * 60;
      Float Mins = new Float(breakTime);
View Full Code Here

      String oldName = flvo.getName();

      Calendar c = Calendar.getInstance();
      java.util.Date dt = c.getTime();
      DateFormat df = new SimpleDateFormat("MM_dd_yyyy_hh_mm_ss");
      String dateStamp = df.format(dt);

      // String newName = fileId + "_" + flvo.getTitle();

      String newName = "attachment_" + dateStamp + "_" + flvo.getTitle();
View Full Code Here

          CvFolderVO homeFld = remoteFile.getHomeFolder(indvID);

          int rn = (new Random()).nextInt();
          Calendar c = Calendar.getInstance();
          java.util.Date dt = c.getTime();
          DateFormat df = new SimpleDateFormat("MM_dd_yyyy");
          String dateStamp = df.format(dt);

          CvFileVO flvo = new CvFileVO();
          flvo.setTitle("Error Log");
          flvo.setName("errorLog_" + indvID + "_" + rn + "_" + dateStamp + ".txt");
          messageList.put("fileName","errorLog_" + indvID + "_" + rn + "_" + dateStamp + ".txt");
View Full Code Here

  }

  //  ================== Parse String TO date/time/timestamp  ==================
  private static Date parseDateHelper(String date, String format)
      throws FunctionExecutionException {
    DateFormat df = new SimpleDateFormat(format);
    try {
      return df.parse(date);
    } catch (ParseException e) {
      throw new FunctionExecutionException("ERR.015.001.0043", QueryPlugin.Util.getString("ERR.015.001.0043" , //$NON-NLS-1$ //$NON-NLS-2$
          date, format));
    }
  }
View Full Code Here

   * @return ActivityForm
   */
  public ActivityForm fillBasicForm(ActivityVO activity, ActivityForm activityForm)
  {
    try {
      DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, activityForm.getLocale());
      DateFormat tf = DateFormat.getTimeInstance(DateFormat.SHORT, activityForm.getLocale());

      activityForm.setActivityType(String.valueOf(activity.getActivityType()));
      activityForm.setActivityID(String.valueOf(activity.getActivityID()));
      activityForm.setActivityTitle(activity.getTitle());
      activityForm.setActivityPriority(String.valueOf(activity.getPriority()));

      // Set the RelatedField Information:
      activityForm.setActivityRelatedFieldID(Integer.toString(activity.getRelatedFieldID()));
      activityForm.setActivityRelatedFieldValue(activity.getRelatedFieldValue());
      activityForm.setActivityRelatedTypeID(Integer.toString(activity.getRelatedTypeID()));
      activityForm.setActivityRelatedTypeValue(activity.getRelatedTypeValue());

      if (activity.getNotes() != null) {
        activityForm.setActivityNotes(String.valueOf(activity.getNotes()));
      } else {
        activityForm.setActivityNotes("");
      }

      activityForm.setActivityCallType(String.valueOf(activity.getCallTypeId()));
      activityForm.setActivityID(String.valueOf(activity.getActivityID()));

      if (activity.getActivityDetails() != null) {
        activityForm.setActivityDetail(activity.getActivityDetails());
      }

      if (activity.getActivityStartDate() != null) {
        Timestamp startTimeStamp = activity.getActivityStartDate();
        Calendar start = new GregorianCalendar();
        start.setTime(startTimeStamp);
        activityForm.setActivityStartDate(df.format(start.getTime()));
        activityForm.setActivityStartTime(tf.format(start.getTime()));
      }

      if (activity.getActivityEndDate() != null) {
        Timestamp endTimeStamp = activity.getActivityEndDate();
        Calendar end = new GregorianCalendar();
        end.setTime(endTimeStamp);
        activityForm.setActivityEndDate(df.format(end.getTime()));
        activityForm.setActivityEndTime(tf.format(end.getTime()));
      }

      RecurrenceVO recurrenceVO = null;
      if (activity.getRecurrence() != null) {
        recurrenceVO = activity.getRecurrence();
        activityForm.setActivityRecurringFrequency(recurrenceVO.getTimePeriod());

        // if date is not null convert from timestamp to String
        if (recurrenceVO.getStartDate() != null) {
          Date recurStartDate = recurrenceVO.getStartDate();
          Calendar recurStart = new GregorianCalendar();
          recurStart.setTime(recurStartDate);
          activityForm.setActivityRecurStartDate(df.format(recurStart.getTime()));
          activityForm.setActivityRecurringStartTime(tf.format(recurStart.getTime()));
        }

        if (recurrenceVO.getUntil() != null) {
          Date recurEndDate = recurrenceVO.getUntil();
          Calendar recurEnd = new GregorianCalendar();
          recurEnd.setTime(recurEndDate);
          activityForm.setActivityRecurEndDate(df.format(recurEnd.getTime()));
        }

        HashMap mapRecurrence = recurrenceVO.getRecurrenceHM();
        if (mapRecurrence != null) {
          if (mapRecurrence.size() > 0) {
            String frequency = (String)mapRecurrence.get("FREQUENCY");
            String every = (String)mapRecurrence.get("EVERY");
            String on = (String)mapRecurrence.get("ON");
            activityForm.setActivityRecurringFrequency(frequency);

            if (frequency.equals("DAY")) {
              activityForm.setActivityRecurringDailyEvery("1");
              activityForm.setActivityRecurringDailyDays(every);
              if (Integer.parseInt(on) > 0) {
                activityForm.setActivityRecurringDailyWeekdays("1");
              }
            } else if (frequency.equals("WEEK")) {
              activityForm.setActivityRecurringWeeklyEvery(every);
              StringTokenizer st = new StringTokenizer(on, ",");
              String strweeklyon[] = new String[st.countTokens()];
              int i = 0;

              while (st.hasMoreTokens()) {
                String strToken = st.nextToken();
                if (strToken.equals("6")) {
                  strToken = "Su";
                } else if (strToken.equals("0")) {
                  strToken = "Mo";
                } else if (strToken.equals("1")) {
                  strToken = "Tu";
                } else if (strToken.equals("2")) {
                  strToken = "We";
                } else if (strToken.equals("3")) {
                  strToken = "Th";
                } else if (strToken.equals("4")) {
                  strToken = "Fr";
                } else if (strToken.equals("5")) {
                  strToken = "Sa";
                }
                strweeklyon[i] = strToken.trim();
                i++;
              }
              String selectedweek[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" };
              activityForm.setActivityRecurringWeeklyOn(strweeklyon);
              activityForm.setActivitySelectedWeek(selectedweek);
              activityForm.setActivityFindWeek(strweeklyon);
            } else if (frequency.equals("MONTH")) {
              String onstring = on;
              int inton = Integer.parseInt(onstring.substring(0, 1));
              activityForm.setActivityRecurringMonthlyEvery("" + inton);
              if (inton == 0) {
                String monthday = onstring.substring(2, onstring.length());
                activityForm.setActivityRecurringMonthlyEveryDay(monthday);
                activityForm.setActivityRecurringMonthlyOnWeek("-1");
                activityForm.setActivityRecurringMonthlyOnDay("-1");
              }

              if (inton == 1) {
                activityForm.setActivityRecurringMonthlyOnDay(onstring.substring(2, 3));
                activityForm.setActivityRecurringMonthlyOnWeek(onstring.substring(4, 5));
              }
            } else if (frequency.equals("YEAR")) {
              String onstring = on;
              int inton = Integer.parseInt(onstring.substring(0, 1));
              activityForm.setActivityRecurringYearlyEvery("" + inton);
              if (inton == 0) {
                activityForm.setActivityRecurringYearlyEveryMonth(every);
                String yearday = onstring.substring(2, onstring.length());
                activityForm.setActivityRecurringYearlyEveryDay(yearday);
                activityForm.setActivityRecurringYearlyOnWeek("-1");
                activityForm.setActivityRecurringYearlyOnDay("-1");
              }

              if (inton == 1) {
                activityForm.setActivityRecurringYearlyOnMonth(every);
                activityForm.setActivityRecurringYearlyOnWeek(onstring.substring(2, 3));
                activityForm.setActivityRecurringYearlyOnDay(onstring.substring(4, 5));
              }
            }// end of else if (frequency.equals("YEAR"))
          }// end of if (mapRecurrence.size()>0)
        }// end of if (mapRecurrence != null)
      }// end of if (actVo.getRecurrence() != null)

      Collection activityAction = null;
      if (activity.getActivityAction() != null) {
        activityAction = activity.getActivityAction();
        Iterator it = activityAction.iterator();
        while (it.hasNext()) {
          ActivityActionVO acVO = (ActivityActionVO)it.next();
          String strActionType = acVO.getActionType();
          if (strActionType.equals(ActivityActionVO.AA_ALERT)) {
            activityForm.setActivityReminder("on");
            if (acVO.getActionTime() != null) {
              Timestamp remindTimeStamp = acVO.getActionTime();
              Calendar remind = new GregorianCalendar();
              remind.setTime(remindTimeStamp);
              activityForm.setActivityRemindDate(df.format(remind.getTime()));
              activityForm.setActivityReminderTime(tf.format(remind.getTime()));
            }// end of if (acVO.getActionTime() != null)
          }// end of if (strActionType.equals(ActivityActionVO.AA_ALERT))
          else if (strActionType.equals(ActivityActionVO.AA_EMAIL)) {
            activityForm.setActivityEmailInvitation("on");
          }// end of else if (strActionType.equals(ActivityActionVO.AA_EMAIL))
View Full Code Here

   * @param activity The newly created ActitivityVO object
   * @return void
   */
  public void fillBasic(ActivityVO activity, ActivityForm activityForm)
  {
    DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, activityForm.getLocale());
    DateFormat tf = DateFormat.getTimeInstance(DateFormat.SHORT, activityForm.getLocale());

    String id = activityForm.getActivityID();
    if ((id != null) && (id.length() > 0)) {
      activity.setActivityID(Integer.parseInt(id));
    }
    String activityType = activityForm.getActivityType();
    if ((activityType != null) && (activityType.length() > 0)) {
      activity.setActivityType(Integer.parseInt(activityForm.getActivityType()));
    }
    activity.setTitle(activityForm.getActivityTitle());
    activity.setActivityDetails(activityForm.getActivityDetail());
    if ((activityForm.getActivityRelatedFieldID() != null)
        && (activityForm.getActivityRelatedFieldID().length() > 0)
        && (activityForm.getActivityRelatedTypeID() != null)
        && (activityForm.getActivityRelatedTypeID().length() > 0)) {
      activity.setRelatedFieldID(Integer.parseInt(activityForm.getActivityRelatedFieldID()));
      activity.setRelatedFieldValue(activityForm.getActivityRelatedFieldValue());
      activity.setRelatedTypeID(Integer.parseInt(activityForm.getActivityRelatedTypeID()));
      activity.setRelatedTypeValue(activityForm.getActivityRelatedTypeValue());
    }
    if ((activityForm.getActivityEntityID() != null)
        && (activityForm.getActivityEntityID().length() > 0)) {
      String entity = activityForm.getActivityEntityID();
      activity.setEntityID(Integer.parseInt(entity));
    }
    if ((activityForm.getActivityIndividualID() != null)
        && (activityForm.getActivityIndividualID().length() > 0)) {
      String individual = activityForm.getActivityIndividualID();
      activity.setIndividualID(Integer.parseInt(individual));
    }
    if ((activityForm.getActivityCallType() != null)
        && (activityForm.getActivityCallType().length() > 0)) {
      String callType = activityForm.getActivityCallType();
      activity.setCallTypeId(Integer.parseInt(callType));
    }

    if (CVUtility.notEmpty(activityForm.getActivityStartDate())) {
      Calendar start = new GregorianCalendar();
      Calendar startTime = new GregorianCalendar();
      try {
        logger.debug("dateformat: "+df.toString()+", lenient?: "+df.isLenient()+", locale: "+activityForm.getLocale());
        start.setTime(df.parse(activityForm.getActivityStartDate()));
        startTime.setTime(tf.parse(activityForm.getActivityStartTime()));
        logger.debug("parsed start date: "+df.format(start.getTime()));
        logger.debug("parsed start time: "+tf.format(startTime.getTime()));
      } catch (ParseException e) {
        logger.error("[fillBasic]: Can't parse start date or time", e);
      }
      start.set(Calendar.HOUR, startTime.get(Calendar.HOUR));
      start.set(Calendar.MINUTE, startTime.get(Calendar.MINUTE));
      start.set(Calendar.AM_PM, startTime.get(Calendar.AM_PM));
      activity.setActivityStartDate(new Timestamp(start.getTimeInMillis()));
    }

    if (CVUtility.notEmpty(activityForm.getActivityEndDate())) {
      Calendar end = new GregorianCalendar();
      Calendar endTime = new GregorianCalendar();
      try {
        end.setTime(df.parse(activityForm.getActivityEndDate()));
        endTime.setTime(tf.parse(activityForm.getActivityEndTime()));
        logger.debug("parsed end date: "+df.format(end.getTime()));
        logger.debug("parsed end time: "+tf.format(endTime.getTime()));
      } catch (ParseException e) {
        logger.error("[fillBasic]: Can't parse end date or time", e);
      }
      end.set(Calendar.HOUR, endTime.get(Calendar.HOUR));
      end.set(Calendar.MINUTE, endTime.get(Calendar.MINUTE));
      end.set(Calendar.AM_PM, endTime.get(Calendar.AM_PM));
      activity.setActivityEndDate(new Timestamp(end.getTimeInMillis()));
    }

    if ((activityForm.getActivityOwnerID() != null)
        && (activityForm.getActivityOwnerID().length() > 0)) {
      activity.setOwner(Integer.parseInt(activityForm.getActivityOwnerID()));
    }
    try {
      String tmpPriority = activityForm.getActivityPriority();
      if ((tmpPriority != null) && (!tmpPriority.equals(""))) {
        activity.setPriority(Integer.parseInt(tmpPriority));
      } else {
        activity.setPriority(2);
      }
    } catch (Exception e) {
      activity.setPriority(2);
    }
    if ((activityForm.getActivityNotes() != null) && (activityForm.getActivityNotes().length() > 0)) {
      activity.setNotes(activityForm.getActivityNotes());
    }
    try {
      String tmpStatus = activityForm.getActivityStatus();
      if ((tmpStatus != null) && (!tmpStatus.equals(""))) {
        activity.setStatus(Integer.parseInt(tmpStatus));
      } else {
        activity.setStatus(2);
      }
    } catch (Exception e) {
      activity.setStatus(2);
    }
    activity.setVisibility(activityForm.getActivityVisibility());
    String reminder = activityForm.getActivityReminder();
    if (activityForm.getActivityReminder() != null && reminder.equals("on")) {
      ActivityActionVO action = new ActivityActionVO();
      action.setActionType(ActivityActionVO.AA_ALERT);
      // FIXME externalize String
      action.setMessage("Scheduled Alert: " + activity.getTitle());
      action.setInterval(0);
      action.setRepeat(0);
      if (CVUtility.notEmpty(activityForm.getActivityRemindDate())
          && CVUtility.notEmpty(activityForm.getActivityReminderTime())) {
        Calendar remind = new GregorianCalendar();
        Calendar remindTime = new GregorianCalendar();
        try {
          remind.setTime(df.parse(activityForm.getActivityRemindDate()));
          remindTime.setTime(tf.parse(activityForm.getActivityReminderTime()));
        } catch (ParseException e) {
          logger.error("[fillBasic]: Exception", e);
        }
        remind.set(Calendar.HOUR, remindTime.get(Calendar.HOUR));
        remind.set(Calendar.MINUTE, remindTime.get(Calendar.MINUTE));
View Full Code Here

  /*
   * See PrimitiveOrWrapperConverterTest for more thorough data conversion unit tests
   */
  @Test
  public void testAccessors() throws Exception {
    DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);

    CalendarConverter cc = new CalendarConverter(dateFormat);
    assertEquals(dateFormat, cc.getDateFormat());

    StringConverter sc = new StringConverter(null);
View Full Code Here

  public String  getDisplayString()
  {   
    if ( memberValue != null )
    {
      DateFormat df = new SimpleDateFormat("MMM d, yyyy") ;
      return df.format(memberValue);
    }else
    {
      return "";
    }
  } 
View Full Code Here

      return (DateStringFormatConfig) configObj;
    }
  }

  protected static Date parseDateString(DateStringFormatConfig formatConfig, String dateStr) throws ParseException {
    DateFormat dateFormat = formatConfig.getDateFormat();
    return dateFormat.parse(dateStr);
  }
View Full Code Here

TOP

Related Classes of java.text.DateFormat$DateFormatGetter

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.