cancel
Showing results for 
Search instead for 
Did you mean: 

Date format with NamedValue(String, String) to d:date

jbaton
Champ in-the-making
Champ in-the-making
Hello Roy and people from the world,

Could you tell me what is the format to use to create a NamedValue representing a date so that it gets stored properly into a d:date property.

Thanks


JBaton
8 REPLIES 8

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

Should be passed in ISO8601 format. Try this format:

YYYY-MM-DDThh:mm:ss

Cheers,
Roy

jbaton
Champ in-the-making
Champ in-the-making
Roy,

Using this pattern with a SimpleDateFormat does not work.

Looking at some class called "*ISO8601*" (sorry I'm not in front of my pc right now) in the Alfresco code, it seems that the milliseconds and the timezone are needed too.

(I use d:datetime not d:date as previously said)


JBaton

kevinr
Star Contributor
Star Contributor
I believe the full ISO format date is:

YYYY-MM-DDThh:mm:ss.mmm+hh:mm

where mmm is miliseconds and +hh:mm is the offset from the GMT time zone, for example:

2005-09-16T17:01:03.456+01:00

Hope this helps,

Kevin

jbaton
Champ in-the-making
Champ in-the-making
Thanks Kevin, Roy,

I used the class org.alfresco.util.ISO8601DateFormat as a converter from java.util.Date to String for use with the web service api.

I think dates usage should be part of the (very helpful) samples.


Jerome BATON

pitti
Champ in-the-making
Champ in-the-making
Can u give me an example to store the d:date in NamedValue class
Help needed please

jbaton
Champ in-the-making
Champ in-the-making
Hi, I don't have the Alfresco sources in front of me so my help right now will be limited.

You'd better look in the alfresco sources at the class I mentionned in the previous post, you'll see the expected format for dates.


Then create a NamedValue
with
{YourNameSpaceURIAsDefinedInYourModel}yourPropertyName  as key
and
the formatted date (as a String) as the value


I don't remember if I used d:date or d:datetime.
If ever you change a property type in an aspect, remember to remove the aspect off the space then to reapply it.

Hope it helps

Jerome BATON
http://www.wadael.org (photos, writings in french)

pitti
Champ in-the-making
Champ in-the-making
I changed my code according to your suggestions and it is working fine
Thanks for your immediate response
Regards
Keshav

dnalos
Champ in-the-making
Champ in-the-making
I have other problem like this. I have define a "date" in my customModel.xml like this:

         <property name="custom:datum">
            <title>Datum</title>
            <type>d:date</type>
         </property>

And my question is, how can i search a Node with a date property? Like this?
@custom\:datum:2009-*-14

Thank you.