cancel
Showing results for 
Search instead for 
Did you mean: 

How to use created date??

jjhinojosa
Champ in-the-making
Champ in-the-making
Hi,

I need to use the created date of the document to compare it with other date. I use the next

QName fechaComision = QName.createQName("my.new.model", "fecha");

, but I dont know attributes that I need to create QName of created date.


Sorry for my english
2 REPLIES 2

jjhinojosa
Champ in-the-making
Champ in-the-making
This is my implementation

            QName fechaComision = QName.createQName("my.new.model", "fecha");
            QName fechaCreacion = ContentModel.PROP_ARCHIVED_DATE;
            Map propiedades = this.nodeService.getProperties(actionedUponNodeRef);
           
            Date fechaCo = (Date)propiedades.get(fechaComision);
            Date fechaCre = (Date)propiedades.get(fechaCreacion);
           
            //Date fechaCo=(Date)this.nodeService.getProperty(actionedUponNodeRef, fechaComision);
            //Date fechaCre=(Date)this.nodeService.getProperty(actionedUponNodeRef, fechaCreacion);
            System.out.println(fechaCo.toString());
            System.out.println(fechaCre.toString());
            long time = fechaCo.getTime() - fechaCre.getTime();
           
          //          Muestro el resultado en días
            int dias=(int)(time/(3600*24*1000));
            if (dias<7)
            {
              
               this.nodeService.setProperty(actionedUponNodeRef, fechaComision, fechaCre);
            }


The error is in System.out.println(fechaCre.toString()); , but I dont know why. I think that the bad line is this
QName fechaCreacion = ContentModel.PROP_ARCHIVED_DATE;

jjhinojosa
Champ in-the-making
Champ in-the-making
Resolved problem, the problem is that I was confused, which was searching was not PROP_ARCHIVED_DATE, but what was looking age for the property "cm:created" of the aspect auditable, therefore only I have had to change the line

QName fechaCreacion = ContentModel. PROP_ARCHIVED_DATE;

For this other one

QName fechaCreacion = QName.createQName (" http://www.alfresco.org/model/content/1.0 ", "created");

I hope that this can serve someone in a future.