[Hippo-cms7-user] the dateformat for dates in JCR

Bart van der Schans b.vanderschans at onehippo.com
Thu Dec 9 10:55:45 CET 2010


Just wondering:

- what is the difference between new GregorianCalendar() and
Calendar.getInstance()?
- should the instance be constructed with a timezone and/or locale?

Regards,
Bart


On Thu, Dec 9, 2010 at 10:44 AM, Jeroen Reijn <j.reijn at onehippo.com> wrote:
> Bert,
> you do not need to format the date. That's only the way it's represented.
> You can just use a simple java.util.Date in combination with a Calendar.
> From your plugin you will get a normal Date object I presume? The JCR api
> just expects a Calendar object.
> So the following should be fine.
> Calendar publicationDateCalendar = new GregorianCalendar();
> publicationDateCalendar.setTime(myDate);
> node.setProperty(DocumentTypes.Document.PUBLICATION_DATE,
> publicationDateCalendar);
> Where node is a simple jcr Node and DocumentTypes.Document.PUBLICATION_DATE
> is of type (date) in the cnd.
> Cheers,
> Jeroen
> On Thu, Dec 9, 2010 at 10:32 AM, Bert Leunis <b.leunis at onehippo.com> wrote:
>>
>> Hello,
>>
>> I worked on a dasboardplugin for the cms in our project. It works as in
>> the GoGreen demo. After clicking "Create a news document" you can choose a
>> date. The value of the date determines in which folder your news document is
>> placed (e.g. /2010/12/mydocument). It is possible to use this date in the
>> creation query of the document, and automatically fill in the date in one or
>> more of the fields in the document.
>>
>> The date now has to be formatted in the way JCR expects it, otherwise you
>> get an error. I found out that the good old java.text.SimpleDateFormat can
>> NOT deliver the right format:
>>
>> 2010-12-09T10:27:52.688+01:00
>>
>> The timezone part at the end with a semicolon does not belong to
>> SimpleDateFormats possibilities. I had to use the jodatime formatter to get
>> the right format.
>>
>> DateTimeFormatter fmt =
>> DateTimeFormat.forPattern("yyyy-MM-dd'T'kk:mm:ss.SSSZZ");
>> fmt.print(date.getTime());
>>
>> Is there a better way to do this? Is there a utility in the cms that can
>> deliver me the correct date format?
>> --
>> With kind regards/Met vriendelijke groet,
>> Bert Leunis
>> Hippo
>> Europe  •  Amsterdam  Oosteinde 11  •  1017 WT Amsterdam  •  +31 (0)20 522
>> 4466
>> USA  • San Francisco 755 Baywood Drive, Second Floor •  Petaluma, CA.
>> 94954 •  +1 877 414 4776 (toll free)
>> Canada    •   Montréal  5369 Boulevard St-Laurent #430 •  Montréal QC
>> H2T 1S5  •  +1 (514) 316 8966
>> www.onehippo.com  •  www.onehippo.org  •  info at onehippo.com
>> ________________________________________________________________
>> This e-mail may be privileged and/or confidential, and the sender does
>> not waive any related rights and obligations. Any distribution, use or
>> copying of this e-mail or the information it contains by other than an
>> intended recipient is unauthorized. If you received this e-mail in
>> error, please advise me (by return e-mail or otherwise) immediately.
>>
>> _______________________________________________
>> Hippo-cms7-user mailing list and forums
>> http://www.onehippo.org/cms7/support/forums.html
>
>
>
> --
> Hippo
> ----------------------------------------------------------------------------------------------
> Europe  •  Amsterdam  Oosteinde 11  •  1017 WT Amsterdam  •  +31 (0)20 522
> 4466
> USA  • 755 Baywood Drive Second Floor  •  Petaluma CA. 94954
> •  +1 877 414-4776 (toll free)
> Canada    •   Montréal  5369 Boulevard St-Laurent #430 •  Montréal QC
> H2T 1S5  •  +1 (514) 316 8966
> ----------------------------------------------------------------------------------------------
> www.onehippo.com  •  www.onehippo.org  •  info at onehippo.com
> ----------------------------------------------------------------------------------------------
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html
>



-- 
Hippo
----------------------------------------------------------------------------------------------
Europe  •  Amsterdam  Oosteinde 11  •  1017 WT Amsterdam  •  +31 (0)20 522 4466
USA  • San Francisco  755 Baywood Drive  •  Petaluma CA. 94954 •  +1
(877) 414 4776
Canada    •   Montréal  5369 Boulevard St-Laurent #430 •  Montréal QC
H2T 1S5  •  +1 (707) 658-4535
----------------------------------------------------------------------------------------------
www.onehippo.com  •  www.onehippo.org  •  info at onehippo.com
----------------------------------------------------------------------------------------------



More information about the Hippo-cms7-user mailing list