Examples of DateFormat


Examples of java.text.DateFormat

  }

  //  ================== 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

Examples of java.text.DateFormat

   * @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

Examples of java.text.DateFormat

   * @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

Examples of java.text.DateFormat

  /*
   * 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

Examples of java.text.DateFormat

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

Examples of java.text.DateFormat

      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

Examples of jxl.write.DateFormat

  }

  protected DateFormat getDateFormat(String pattern)
  {
    String convertedPattern = getConvertedPattern(pattern);
    DateFormat cellFormat = (DateFormat) dateFormats.get(convertedPattern);
    if (cellFormat == null)
    {
      cellFormat = new DateFormat(convertedPattern);
      dateFormats.put(convertedPattern, cellFormat);
    }
    return cellFormat;
  }
View Full Code Here

Examples of net.helipilot50.stocktrade.framework.DateFormat

    private Class<?> mappedType;
    private static final Pattern placeholderPattern = Pattern.compile("<(.)>");
    public DateTemplate(DataField component, TextData value) {
        super(component);
        this.template = value;
        this.formatter = new DateFormat();
    }
View Full Code Here

Examples of net.rim.device.api.i18n.DateFormat

     */
    public static String getDateAsString(final Date date, final int style) {
        String dateString = null;

        if (date != null) {
            final DateFormat dateFormat = DateFormat.getInstance(style);
            dateString = dateFormat.formatLocal(date.getTime());
        }

        return dateString;
    }
View Full Code Here

Examples of org.conventionsframework.qualifier.DateFormat

    Map<String,SimpleDateFormat> dateFormatCache = new HashMap<String,SimpleDateFormat>();

    @Produces
    @DateFormat
    public SimpleDateFormat getDateFormat(InjectionPoint ip){
        DateFormat df = ip.getAnnotated().getAnnotation(DateFormat.class);
        String pattern = df.pattern();
        if(dateFormatCache.containsKey(pattern)){
            return dateFormatCache.get(pattern);
        }
        SimpleDateFormat sdf = new SimpleDateFormat(df.pattern());
        dateFormatCache.put(pattern,sdf);
        return sdf;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.