You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by wendy Lee <ha...@gmail.com> on 2006/11/18 16:13:51 UTC

How to write this query which can contraint the datetime type property in appointed parameter

Is this right?
"//wd:resources//element(*,wd:mlv)[@wd:created > "+ lastWeek+ "]"


here "lastWeek" is Java Date Type.

Re: How to write this query which can contraint the datetime type property in appointed parameter

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 11/20/06, wendy Lee <ha...@gmail.com> wrote:
> Can  I  convert the date  to compliant format   by the SimpleDateFormatter
> Class ?  Or Maybe you can give me an example of " fn:dateTime" in the java
> Code .

The easiest way is probably to use the built-in date formatting
functionality in JCR Values.

    Calendar date = ...;
    session.getValueFactory().getValue(date).getString();

BR,

Jukka Zitting

Re: How to write this query which can contraint the datetime type property in appointed parameter

Posted by wendy Lee <ha...@gmail.com>.
Can  I  convert the date  to compliant format   by the SimpleDateFormatter
Class ?  Or Maybe you can give me an example of " fn:dateTime" in the java
Code . Thank you

Re: How to write this query which can contraint the datetime type property in appointed parameter

Posted by Marcel Reutegger <ma...@gmx.net>.
wendy Lee wrote:
> Is this right?
> "//wd:resources//element(*,wd:mlv)[@wd:created > "+ lastWeek+ "]"
> 
> here "lastWeek" is Java Date Type.

No, that won't work. you have to use the constructor function fn:dateTime() with 
a string parameter that conforms to ISO8601. See also jsr 170 spec section 6.2.5.1:

"The text format of dates must follow the following ISO 8601:2000-
compliant format:
sYYYY - MM - DD T hh : mm : ss . sssTZD
where:
sYYYY Four-digit year with optional leading positive (‘ + ’) or
negative (‘ - ’) sign. A negative sign indicates a year BCE. The
absence of a sign or the presence of a positive sign indicates a year
CE (for example, -0055 would indicate the year 55 BCE, while
+1969 and 1969 indicate the year 1969 CE).
MM Two-digit month (01 = January, etc.)
DD Two-digit day of month (01 through 31)
hh Two digits of hour (00 through 23)
mm Two digits of minute (00 through 59)
ss.sss Seconds, to three decimal places (00.000
through 59.999)
TZD Time zone designator (either Z for Zulu, i.e. UTC, or
+hh:mm or -hh:mm, i.e. an offset from UTC)

Note that the "T" separating the date from the time and the
separators "-" and ":" appear literally in the string. See
http://www.w3.org/TR/NOTE-datetime for more information."

regards
  marcel