AnsweredAssumed Answered

Problem setting date properties

Question asked by mistergerf on Aug 14, 2006
Latest reply on Dec 13, 2006 by jpotts
Trying to set the date created and updated for a content node, here's my code:

String dateCreated = document.getDateCreated().toString();
String dateUpdated = document.getDateUpdated().toString();
       
NamedValue[] properties =
         new NamedValue[]{
Utils.createNamedValue(Constants.PROP_DESCRIPTION, document.getDescription()),
                  Utils.createNamedValue(Constants.PROP_TITLE, document.getTitle()),
                  Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}author", document.getAuthors()),
                  Utils.createNamedValue(Constants.PROP_NAME, document.getFileName()),
                  //Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}created", dateCreated),
                  Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}modified", dateUpdated)
                  };

              logger.warn("Creating: " + document.getFileName());
               
               CMLCreate create = new CMLCreate("1", parentReference, Constants.TYPE_CONTENT, properties);
               CML cml = new CML();
               cml.setCreate(new CMLCreate[]{create});
               UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cml); 

               ContentFormat format = new ContentFormat(document.getMimeType(), document.getEncoding());
            
            WebServiceFactory.getContentService().write(results[0].getDestination(), Constants.PROP_CONTENT, document.getContentAsByteArr(), format);
   

The "getRepositoryService.update(cml)" throws the exception:

message1   "Failed to convert date 2006-07-07 to string"   

document.getDateCreated() returns a Date

Any ideas ?

Outcomes