Package java.text

Examples of java.text.SimpleDateFormat$CompiledField


     */
     private String date2String(Date date,String timePattern) {
       if(timePattern == null || timePattern.trim().isEmpty() ){
         timePattern = "yyyy-MM-dd'T'HH:mm:ssZ";
       }
       SimpleDateFormat   formatter   = new SimpleDateFormat(timePattern);
       if(JSONCodec.useTimezoneSeparator){
         StringBuffer   dateStr   = new StringBuffer(formatter.format(date));
         return dateStr.length() > 22 ? dateStr.insert(22, ':').toString() : dateStr.toString();
       }else{
         return formatter.format(date);
       }
    }
View Full Code Here


        }
        recalcWidth(date);
      }

      String s = TimeFormatter.DATEFORMATS_DESC[curFormat] + suffix;
      SimpleDateFormat temp = new SimpleDateFormat(s
          + (showTime && multiline ? "\nh:mm a" : ""));
      cell.setText(temp.format(date));
    }
  }
View Full Code Here

      Point minSize = new Point(99999, 0);
      for (int i = 0; i < TimeFormatter.DATEFORMATS_DESC.length; i++) {
        if (maxWidthUsed[i] > width - PADDING) {
          continue;
        }
        SimpleDateFormat temp = new SimpleDateFormat(
            TimeFormatter.DATEFORMATS_DESC[i] + suffix);
        Point newSize = gc.stringExtent(temp.format(date));
        if (newSize.x < width - PADDING) {
          idxFormat = i;
          if (maxWidthUsed[i] < newSize.x) {
            maxWidthUsed[i] = newSize.x;
            maxWidthDate[i] = date;
View Full Code Here

        fd.setStyle(SWT.BOLD);
      }
      fontBold = new Font(gc.getDevice(), fontData);
    }
    gc.setFont(fontBold);
    SimpleDateFormat temp = new SimpleDateFormat(format);
    Point newSize = gc.stringExtent(temp.format(date));
    gc.dispose();
    return newSize.x;
  }
View Full Code Here

     * @since 4.3
     */
    private Timestamp getTimestamp(String startts,
                                   int startnanos,
                                   String starttz) throws ParseException {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); //$NON-NLS-1$
        df.setTimeZone(TimeZone.getTimeZone(starttz));

        Timestamp ts = new Timestamp(df.parse(startts).getTime());
        ts.setNanos(startnanos);
        return ts;
    }
View Full Code Here

  /**
   * @see org.apache.struts.action.ActionForm#validate(ActionMapping, HttpServletRequest)
   */
  public ActionErrors myValidate(HttpServletRequest request) {
    ActionErrors errors = new ActionErrors()
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
    try {
      formatter.parse(getDate());
    } catch( Exception e ) {
      ActionError error = new ActionError("error.general.badDate");
      errors.add("date",error);
    }
    return errors;
View Full Code Here

  /**
   * @see org.apache.struts.action.ActionForm#validate(ActionMapping, HttpServletRequest)
   */
  public ActionErrors myValidate(HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
    if (getType() == null) {
      ActionError error = new ActionError("error.general.missingField");
      errors.add("type", error);
    } else {
      if (getType().equals("P_D")) {
        Date dateBegin = null;
        Date dateEnd = null;
        try {
          dateBegin = formatter.parse(getDateBegin());
        } catch (Exception e) {
          ActionError error =
            new ActionError("error.general.badDate");
          errors.add("date", error);
        }
        if (dateBegin != null) {
          try {
            dateEnd = formatter.parse(getDateEnd());
          } catch (Exception e) {
            ActionError error =
              new ActionError("error.general.badDate");
            errors.add("date", error);
          }
View Full Code Here

    UserObject userobjectd = (UserObject)session.getAttribute("userobject");
    UserPrefererences userPrefs = userobjectd.getUserPref();
    TimeZone tz = TimeZone.getTimeZone(userPrefs.getTimeZone());
    Locale locale = request.getLocale();
    int individualID = userobjectd.getIndividualID();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    // date format for writing to the form should be in the format based on
    // locale
    DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
    DateFormat tf = DateFormat.getTimeInstance(DateFormat.SHORT, locale);

    int activitytype = 0;

    int activityid = Integer.parseInt(requestForm.getActivityID());
    String result = "";

    // created session facade to call EJB methods (SyncFacade is a local class,
    // not an EJB!)
    SyncFacade syncfacade = new SyncFacade();
    syncfacade.setDataSource(dataSource);

    // if session is correct
    if (userobjectd.getSessionID().equals(sessionID)) {
      // A cheap way to check for NullPointerExceptions.
      try {
        ActivityForm activityForm = new ActivityForm();
        activityForm.setLocale(locale);
        activityForm.setActivityID(Integer.toString(activityid));

        String detailpriority = requestForm.getPriority();
        String detailstatus = requestForm.getStatus();

        if (detailstatus == null) {
          detailstatus = "1";
        }

        if (detailstatus != null && !detailstatus.equals("")) {
          if (detailstatus.equals("Pending")) {
            detailstatus = "1";
          } else if (detailstatus.equals("Completed")) {
            detailstatus = "2";
          }
        }

        String detailtitle = requestForm.getTitle();
        String detaildetail = requestForm.getDescription();

        // call to getting activity details
        ActivityVO vo = null;
        activitytype = syncfacade.getActivityType(activityid);
        vo = syncfacade.getActivity(activityid, individualID);

        ActivityGenericFillVOX agf = new ActivityGenericFillVOX();
        activityForm.setLocale(request.getLocale());
        agf.fillBasicForm(vo, activityForm);

        // if user wants to edit any field , that will not be null , so
        // that field is set to ActivityForm

        if (detailpriority != null) {
          activityForm.setActivityPriority(detailpriority);
        }

        if (detailstatus != null) {
          activityForm.setActivityStatus(detailstatus);
        }

        if (detailtitle != null) {
          activityForm.setActivityTitle(detailtitle);
        }

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

        // startdate
        String activitystartdate = requestForm.getStartDateTime();
        Calendar start = new GregorianCalendar(tz, locale);
        if (activitystartdate != null) {
          try {
            Date dd = simpleDateFormat.parse(activitystartdate);
            start.setTime(dd);
          } catch (Exception e) {
            logger.error("[execute]: Exception", e);
          }
        }
        activityForm.setActivityStartDate(df.format(start.getTime()));
        activityForm.setActivityStartTime(tf.format(start.getTime()));

        String activityenddate = requestForm.getEndDateTime();
        Calendar end = new GregorianCalendar(tz, locale);
        if (activityenddate != null) {
          try {
            Date dd = simpleDateFormat.parse(activityenddate);
            end.setTime(dd);
          } catch (Exception e) {
            logger.error("[execute]: Exception", e);
          }
        }
        activityForm.setActivityEndDate(df.format(end.getTime()));
        activityForm.setActivityEndTime(tf.format(end.getTime()));

        // alarm date time
        String alarmDateTime = requestForm.getAlarmDateTime();
        Calendar remind = new GregorianCalendar(tz, locale);
        // if alarmDateTime is not null , so set it to ActivityForm
        if (alarmDateTime != null) {
          try {
            Date d = simpleDateFormat.parse(alarmDateTime);
            remind.setTime(d);
          } catch (Exception e) {
            logger.error("[execute]: Exception", e);
          }
        }
        activityForm.setActivityRemindDate(df.format(remind));
        activityForm.setActivityReminderTime(tf.format(remind));

        activityForm.setActivityType(String.valueOf(activitytype));

        result = syncfacade.updateActivity(activityForm, individualID);

        String recurrenceType = requestForm.getRecurrenceType();

        if (recurrenceType != null && !recurrenceType.equals("")) {
          // This is a recurring activity - update the recurring info
          int every = requestForm.getEvery();
          int recurrOn = requestForm.getOn();
          String recurringStartDateString = requestForm.getStartDateTime();
          String recurringEndDateString = requestForm.getRecurrenceEndDate();

          Date recurringStartDate = null;
          Date recurringEndDate = null;

          try {
            recurringStartDate = simpleDateFormat.parse(recurringStartDateString);
          } catch (Exception dateException) {
            recurringStartDate = null;
          }

          try {
            recurringEndDate = simpleDateFormat.parse(recurringEndDateString);
          } catch (Exception dateException) {
            recurringEndDate = null;
          }

          try {
View Full Code Here

    /**
     * Returns a string containing the clientHost, targetHost, and targetPort.
     */
    public String toString() {
        SimpleDateFormat dateFormat = new SimpleDateFormat( "MM/dd/yyyy hh:mm:ss a zzz" );
        return "Connection from: " + clientHost + " to " + targetHost + ":" + targetPort + " Opened: " + dateFormat.format( timeOpened );
    }
View Full Code Here

      dateFormat = "M/d/yyyy";
      String timeZone = userPref.getTimeZone();
      if (timeZone == null)
        timeZone = "EST";
      GregorianCalendar gCal = new GregorianCalendar(TimeZone.getTimeZone(timeZone));
      SimpleDateFormat dForm = new SimpleDateFormat(dateFormat);
      dForm.setCalendar(gCal);

      String typeOfSave = null;

      if (request.getParameter("typeOfSave") != null)
        typeOfSave = (String)request.getParameter("typeOfSave");
View Full Code Here

TOP

Related Classes of java.text.SimpleDateFormat$CompiledField

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.