Package java.text

Examples of java.text.DateFormat


  @Test
  public void testDateFormat_CustomMapType() throws Exception {
    // Test that date format works for mapping between String and Custom Map Type
    mapper = getMapper(new String[] { "mapMapping3.xml" });
    DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
    String dateStr = "10/15/2005";
    CustomMap src = newInstance(CustomMap.class);
    src.putValue("fieldA", dateStr);

    org.dozer.vo.SimpleObj dest = mapper.map(src, org.dozer.vo.SimpleObj.class);
    assertNotNull("dest field should not be null", dest.getField5());
    assertEquals("dest field contains wrong date value", df.parse(dateStr), dest.getField5().getTime());

    CustomMap remappedSrc = mapper.map(dest, CustomMap.class);
    assertEquals("remapped src field contains wrong date string", dateStr, remappedSrc.getValue("fieldA"));
  }
View Full Code Here


   */
  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) {
View Full Code Here

      if (fieldValue != null) {
        fieldValue = fieldValue.trim();
      } else {
        isError = true;
      }
      DateFormat tf = DateFormat.getTimeInstance(DateFormat.SHORT, locale);
      tf.parse(fieldValue);
      isError = false;
    } catch (Exception e) {
      isError = true;
    }
    if (isError) {
View Full Code Here

  public String  getDisplayString()
  {   
    System.out.println("In display Pure Time ** member string-----------------****");
    if ( memberValue != null )
    {
      DateFormat   df= new SimpleDateFormat("h:mm a");
      return df.format(memberValue);
    }else
    {
      return "";
    }
  } 
View Full Code Here

        ((Date)this.getMemberValue()).setMonth(greg.get(Calendar.MONTH));
        ((Date)this.getMemberValue()).setDate(greg.get(Calendar.DATE));
        ((Date)this.getMemberValue()).setHours(greg.get(Calendar.HOUR_OF_DAY));
        ((Date)this.getMemberValue()).setMinutes(greg.get(Calendar.MINUTE));

        DateFormat df = null;

        // When you set the applyDate to false then
        // it will only display the Date and it will not consider the Time
        if (applyDate)
        {
          df = new SimpleDateFormat(this.getDateFormat());
        }else{
          df = new SimpleDateFormat(this.onlyDateFormat);
        }
        return df.format(this.memberValue);
      }else{
        // if this is a timestamp, then just return a string representation
        return(memberValue.toString());
      }   // end if (! isTimestamp)
    }else{
View Full Code Here

      noteForm.setTitle(noteVO.getTitle());
      noteForm.setDetail(noteVO.getDetail());
      noteForm.setCreatedid(String.valueOf(noteVO.getCreatedBy()));
      noteForm.setCreatedby(noteVO.getCreatedByVO().getFirstName() + " " + noteVO.getCreatedByVO().getLastName());

      DateFormat df = new SimpleDateFormat("MMM-dd-yyyy hh:mm:ss a");
      Timestamp createdTimestamp = noteVO.getCreatedOn();
      String createdDateString = "";
      if (createdTimestamp != null) {
        Date valueDate = new Date(createdTimestamp.getTime());
        createdDateString = df.format(valueDate);
      }
      noteForm.setCreateddate(createdDateString);

      Timestamp modifiedTimestamp = noteVO.getModifiedOn();
      String modyfiedDateString = "";
      if (modifiedTimestamp != null) {
        Date valueDate = new Date(modifiedTimestamp.getTime());
        modyfiedDateString = df.format(valueDate);
      }
      noteForm.setModifieddate(modyfiedDateString);

      if (noteVO.getRelateEntity() > 0) {
        noteForm.setEntityid(String.valueOf(noteVO.getRelateEntity()));
View Full Code Here

        CvFileVO flvo = new CvFileVO();
        flvo.setTitle(fileName); //file name

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

        flvo.setName("attachment_" + dateStamp +"_"+ fileName);
        flvo.setCreatedBy(userid);
        flvo.setOwner(userid);
        flvo.setAuthorId(userid);
View Full Code Here

     
      // Format created time
      Timestamp timeStamp = catVO.getCreatedOn();
      if (timeStamp != null){
        Date d = new Date(timeStamp.getTime());
        DateFormat df = new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a");
        catForm.setCreated(df.format(d));
      }
     
      // Format modified time
      timeStamp = catVO.getModifiedOn();
      if (timeStamp != null){
        Date d = new Date(timeStamp.getTime());
        DateFormat df = new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a");
        catForm.setModified(df.format(d));
      }
     
      catForm.setOwner(catVO.getOwnerVO().getFirstName() + " "
        + catVO.getOwnerVO().getLastName());
      catForm.setOwnerid(new Integer(catVO.getCreatedBy()).toString());
View Full Code Here

          ItemElement ie = new ItemElement();
          IntMember     InvoiceId = new IntMember("InvoiceId",invoiceID[i],'D',"",'T',false,20);
          String invNumStr = "";
          StringMember   InvoiceNum = new StringMember("InvoiceNum",invoiceNum[i],'D',"",'T',false);

          DateFormat   df = new SimpleDateFormat("yyyy-mm-dd") ;
          java.util.Date InvoiceDate = new java.util.Date();
          try{
            InvoiceDate = df.parse(invDateStr[i]) ;
          }
          catch (Exception e){
            e.printStackTrace();
          }
          DateMember invoiceDate = new DateMember ("Date",InvoiceDate,10,"",'T',false,1,"EST");
View Full Code Here

            CvFolderVO homeFld = remoteFile.getHomeFolder(individualID);

            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("Print Template_" + rn);
            flvo.setName("Template_" + "_" + rn + "_" + dateStamp + ".html");
            Message[1] = "Template_" + "_" + rn + "_" + dateStamp + ".html";
View Full Code Here

TOP

Related Classes of java.text.DateFormat

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.