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

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
jbaton
Member II

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

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
rwetherall
Active Member II

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

Hi,

Should be passed in ISO8601 format. Try this format:

YYYY-MM-DDThh:mm:ss

Cheers,
Roy
jbaton
Member II

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

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
Active Member II

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

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
Member II

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

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
Member II

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

Can u give me an example to store the d:date in NamedValue class
Help needed please
jbaton
Member II

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

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
Member II

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

I changed my code according to your suggestions and it is working fine
Thanks for your immediate response
Regards
Keshav
dnalos
Member II

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

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.