Examples of DateFormat


Examples of java.text.DateFormat

  }

  @Test
  public void testStringToDateMapping() throws Exception {
    mapper = getMapper(new String[] { "dozerBeanMapping.xml" });
    DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss:SS");
    String dateStr = "01/29/1975 10:45:13:25";
    TestObject sourceObj = newInstance(TestObject.class);
    sourceObj.setDateStr(dateStr);
    TestObjectPrime result = mapper.map(sourceObj, TestObjectPrime.class);
    assertEquals(df.parse(dateStr), result.getDateFromStr());
    assertEquals(dateStr, df.format(result.getDateFromStr()));

    TestObject result2 = mapper.map(result, TestObject.class);
    assertEquals(df.format(result.getDateFromStr()), result2.getDateStr());
    assertEquals(result.getDateFromStr(), df.parse(result2.getDateStr()));
  }
View Full Code Here

Examples of java.text.DateFormat

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

Examples of java.text.DateFormat

    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);
View Full Code Here

Examples of java.text.DateFormat

    // the portlets
    // set up below.
    HashMap calendarMap = CalendarUtil.getCalendarCollection(startTime, endTime, tz, individualId,
        60, "", dataSource);
    // use default formatters for locale
    DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT, locale);
    DateFormat dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale);

    // email portlet
    MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
    Mail remote = home.create();
    remote.setDataSource(dataSource);
    ArrayList emailFolders = remote.getHomeFolderList(individualId);
    // this modifier gets stuck right in the html of the "Compose" button
    String emailButtonModifier = "";
    if ((emailFolders == null) || (emailFolders.size() < 1)) {
      emailButtonModifier = "disabled=\"true\"";
    }
    request.setAttribute("emailFolders", emailFolders);
    request.setAttribute("emailButtonModifier", emailButtonModifier);

    // calendar portlet

    // for every activity on the calendar list, create a display object, and
    // append it to the list. The list will be iterated and displayed on the JSP
    ArrayList calendarDisplayList = new ArrayList();
    CalendarList calendarList = (CalendarList)calendarMap.get("calendarlist");
    Set listkey = calendarList.keySet();
    Iterator it = listkey.iterator();
    while (it.hasNext()) {
      Integer key = (Integer)it.next();
      CalendarListElement ele = (CalendarListElement)calendarList.get(key);
      Set elekey = ele.keySet();
      Iterator eleit = elekey.iterator();
      while (eleit.hasNext()) {
        CalendarMember calmember = (CalendarMember)ele.get(eleit.next());
        CalendarActivityObject activity = calmember.getActivityobject();
        Calendar start = activity.getStartTime();
        start.setTimeZone(tz);
        Calendar end = activity.getEndTime();
        end.setTimeZone(tz);
        String timeRange = dateTimeFormat.format(start.getTime()) + " - "
            + dateTimeFormat.format(end.getTime());
        String activityStartTime = timeFormat.format(start.getTime());
        // type is that stored in the activitytype database table.
        String activityType = activity.getActivityType();
        String icon = this.determineActivityIcon(activityType);
        activityType = this.convertActivityType(activityType);
View Full Code Here

Examples of java.text.DateFormat

    private void readQuakes(BufferedReader rdr)
        throws IOException, ParseException {
       
        // process actual quake listing input file
        Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        format.setCalendar(calendar);
        String line;
        while ((line = rdr.readLine()) != null) {
           
            // parse the date and milliseconds
            int mark = line.indexOf(' ');
            mark = line.indexOf(' ', mark+1);
            Date date = format.parse(line.substring(0, mark));
            line = line.substring(mark+1).trim();
            mark = line.indexOf(' ');
            int millis = Integer.parseInt(line.substring(0, mark));
            line = line.substring(mark+1).trim();
           
View Full Code Here

Examples of java.text.DateFormat

    // date format for incoming dates: 2004-01-13 15:00:00
    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);

    ActivityAddHandler requestForm = (ActivityAddHandler)form;
    String sessionID = requestForm.getSessionID();

    // check sessionid is matching or not
    if (userobjectd.getSessionID().equals(sessionID)) {
      ActivityForm activityForm = new ActivityForm();
      activityForm.setLocale(locale);
      String priority = requestForm.getPriority();

      // this is the string that we'll pass to the activityform
      // set to 2 (medium) by default
      String detailpriority = "2";

      if (priority != null) {
        // set the String integer value based on the String string value
        // (confused yet?)
        if (priority.equals("High")) {
          detailpriority = "1";
        } else if (priority.equals("Low")) {
          detailpriority = "3";
        }
      }

      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();

      // startdate
      Calendar start = new GregorianCalendar(tz, locale);
      String activityStartDate = requestForm.getStartDateTime();
      if (activityStartDate != null && (!activityStartDate.equals(""))) {
        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()));

      // enddate
      Calendar end = new GregorianCalendar(tz, locale);
      String activityenddate = requestForm.getEndDateTime();
      if (activityenddate != null && (!activityenddate.equals(""))) {
        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()));

      activityForm.setActivityPriority(detailpriority);
      activityForm.setActivityStatus(detailstatus);
      activityForm.setActivityTitle(detailtitle);
      activityForm.setActivityDetail(detaildetail);
View Full Code Here

Examples of java.text.DateFormat

   public void validate(UIFormInput uiInput) throws Exception
   {
      if (uiInput.getValue() == null || ((String)uiInput.getValue()).trim().length() == 0)
         return;
      String s = (String)uiInput.getValue();
      DateFormat stFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
      UIFormDateTimeInput uiDateInput = (UIFormDateTimeInput)uiInput;
      SimpleDateFormat sdf = new SimpleDateFormat(uiDateInput.getDatePattern_().trim());

      UIForm uiForm = ((UIComponent)uiInput).getAncestorOfType(UIForm.class);
      String label;
      try
      {
        label = uiForm.getId() + ".label." + uiInput.getName();
      }
      catch (Exception e)
      {
         label = uiInput.getName();
      }
      Object[] args = {label, s};

      try
      {
         // Specify whether or not date/time parsing is to be lenient.
         sdf.setLenient(false);
         Date stDate = sdf.parse(s);
         s = stFormat.format(stDate);
      }
      catch (Exception e)
      {
         throw new MessageException(new ApplicationMessage("DateTimeValidator.msg.Invalid-input", args));
      }
View Full Code Here

Examples of java.text.DateFormat

    else
    {
      message = record.getMessage();
    }
   
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
    logWriter.println(dateFormat.format(new java.util.Date()));
   
    if (record.getSourceClassName() != null)
    {
      logWriter.println(record.getSourceClassName());
    }
View Full Code Here

Examples of java.text.DateFormat

  protected Store reGetStoreImpl() {
    return store;
  }

  public void testPreviousDates() throws Exception {
    DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");
    ToyClock clock = new ToyClock();
    Store store = getStoreImpl(clock);
    String baseURLString = "http://localhost/";
    CannedDataReader.readCannedData(store, new File("testdata"),
        baseURLString);
    GraphOverTime got = store.getGraphOverTime(Collections
        .singleton((Source) new SourceImpl(baseURLString + "danbri")));
    // one milli after last modification
    Iterator<Date> previousChanges = got.previousChanges(dateFormat
        .parse("20060920123618662"));
    // should get last modification
    assertEquals(dateFormat.parse("20060920123618661"), previousChanges
        .next());
    // eralier one
    assertEquals(dateFormat.parse("19980920123600000"), previousChanges
        .next());
  }
View Full Code Here

Examples of java.text.DateFormat

        .next());
  }

  // 20061006 changed as interface spec changed
  public void testPreviousDates2() throws Exception {
    DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS");
    ToyClock clock = new ToyClock();
    Store store = getStoreImpl(clock);
    String baseURLString = "http://localhost/";
    CannedDataReader.readCannedData(store, new File("testdata"),
        baseURLString);
    GraphOverTime got = store.getGraphOverTime(Collections
        .singleton((Source) new SourceImpl(baseURLString + "danbri")));
    Iterator<Date> previousChanges = got.previousChanges(dateFormat
        .parse("20060920123618661"));
    assertEquals(dateFormat.parse("20060920123618661"), previousChanges
        .next());
    assertEquals(dateFormat.parse("19980920123600000"), previousChanges
        .next());
  }
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.