Package net.sf.saxon.exslt
Class Date
- java.lang.Object
-
- net.sf.saxon.exslt.Date
-
public final class Date extends java.lang.ObjectThis class implements extension functions in the http://exslt.org/dates-and-times namespace.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringdate(java.lang.String dateTime)The date:date function returns the date specified in the date/time string given as the argument.static java.lang.Stringdate(XPathContext context)The date:date function returns the current date.static java.lang.StringdateTime(XPathContext context)The date:date-time function returns the current date and time as a date/time string.static java.lang.StringdayAbbreviation(java.lang.String dateTime)Return the day of the week given in a date as an English day abbreviation: one of 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', or 'Sat'.static java.lang.StringdayAbbreviation(XPathContext context)Return the day of the week given in the current date as an English day abbreviation: one of 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', or 'Sat'.static doubledayInMonth(java.lang.String dateTime)Return the day number of a specified date within the monthstatic doubledayInMonth(XPathContext context)Return the day number of the current date within the monthstatic doubledayInWeek(java.lang.String dateTime)Return the day of the week given in a date as a number.static doubledayInWeek(XPathContext context)Return the day of the week in the current date as a number.static doubledayInYear(java.lang.String dateTime)Return the day number of a specified date within the yearstatic doubledayInYear(XPathContext context)Return the day number of the current date within the yearstatic java.lang.StringdayName(java.lang.String dateTime)Return the day of the week given in a date as an English day name: one of 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday' or 'Friday'.static java.lang.StringdayName(XPathContext context)Return the day of the week given in the current date as an English day name: one of 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday' or 'Friday'.static doubledayOfWeekInMonth(java.lang.String dateTime)Return the day-of-the-week in a month of a date as a number (for example 3 for the 3rd Tuesday in May).static doubledayOfWeekInMonth(XPathContext context)Return the day-of-the-week in a month of the current date as a number (for example 3 for the 3rd Tuesday in May).static doublehourInDay(java.lang.String dateTime)Return the hour of the day in the specified date or date/timestatic doublehourInDay(XPathContext context)Return the current hour of the daystatic booleanleapYear(java.lang.String dateTime)Return true if the year specified in the date/time string given as the argument is a leap year.static booleanleapYear(XPathContext context)Returns true if the current year is a leap yearstatic doubleminuteInHour(java.lang.String dateTime)Return the minute of the hour in the specified date or date/timestatic doubleminuteInHour(XPathContext context)Return the current minute of the hourstatic java.lang.StringmonthAbbreviation(java.lang.String date)Return the month abbreviation from a date.static java.lang.StringmonthAbbreviation(XPathContext context)Return the month abbreviation from the current date.static doublemonthInYear(java.lang.String dateTime)Return the month number from a date.static doublemonthInYear(XPathContext context)Return the month number from the current date.static java.lang.StringmonthName(java.lang.String date)Return the month name from a date.static java.lang.StringmonthName(XPathContext context)Return the month name from the current date.static doublesecondInMinute(java.lang.String dateTime)Return the second of the minute in the specified date or date/timestatic doublesecondInMinute(XPathContext context)Return the current second of the minutestatic java.lang.Stringtime(java.lang.String dateTime)The date:time function returns the time specified in the date/time string given as the argument.static java.lang.Stringtime(XPathContext context)The date:time function returns the current time.static doubleweekInMonth(java.lang.String dateTime)Return the week number of a specified date within the month (Note, this function is underspecified in EXSLT)static doubleweekInMonth(XPathContext context)Return the ISO week number of the current date within the monthstatic doubleweekInYear(java.lang.String dateTime)Return the ISO week number of a specified date within the year (Note, this returns the ISO week number: the result in EXSLT is underspecified)static doubleweekInYear(XPathContext context)Return the ISO week number of the current datestatic doubleyear(java.lang.String dateTime)The date:year function returns the year specified in the date/time string given as the argument.static doubleyear(XPathContext context)The date:year function returns the current year.
-
-
-
Method Detail
-
dateTime
public static java.lang.String dateTime(XPathContext context) throws XPathException
The date:date-time function returns the current date and time as a date/time string. The date/time string that's returned must be a string in the format defined as the lexical representation of xs:dateTime in [3.2.7 dateTime] of [XML Schema Part 2: Datatypes]. The date/time format is basically CCYY-MM-DDThh:mm:ss+hh:mm. The date/time string format must include a time zone, either a Z to indicate Coordinated Universal Time or a + or - followed by the difference between the difference from UTC represented as hh:mm.- Parameters:
context- the XPath dynamic context- Returns:
- the current date and time as a date/time string
- Throws:
XPathException
-
date
public static java.lang.String date(java.lang.String dateTime)
The date:date function returns the date specified in the date/time string given as the argument.- Parameters:
dateTime- must start with [+|-]CCYY-MM-DD- Returns:
- the date portion of the supplied dateTime
-
date
public static java.lang.String date(XPathContext context) throws XPathException
The date:date function returns the current date.- Parameters:
context- the XPath dynamic context- Returns:
- the current date as a string
- Throws:
XPathException
-
time
public static java.lang.String time(java.lang.String dateTime)
The date:time function returns the time specified in the date/time string given as the argument.- Parameters:
dateTime- must start with [+|-]CCYY-MM-DDThh:mm:ss- Returns:
- the time part of the string
-
time
public static java.lang.String time(XPathContext context) throws XPathException
The date:time function returns the current time.- Parameters:
context- the XPath dynamic context- Returns:
- the current time as a string
- Throws:
XPathException
-
year
public static double year(java.lang.String dateTime)
The date:year function returns the year specified in the date/time string given as the argument.- Parameters:
dateTime- must begin with CCYY- Returns:
- the year part of the supplied date/time
-
year
public static double year(XPathContext context) throws XPathException
The date:year function returns the current year.- Parameters:
context- the XPath dynamic context- Returns:
- the current year as a double
- Throws:
XPathException
-
leapYear
public static boolean leapYear(java.lang.String dateTime)
Return true if the year specified in the date/time string given as the argument is a leap year.- Parameters:
dateTime- a dateTime as a string- Returns:
- true if the year is a leap year
-
leapYear
public static boolean leapYear(XPathContext context) throws XPathException
Returns true if the current year is a leap year- Parameters:
context- the XPath dynamic context- Returns:
- true if the current year is a leap year
- Throws:
XPathException
-
monthInYear
public static double monthInYear(java.lang.String dateTime)
Return the month number from a date. The date must start with either "CCYY-MM" or "--MM"- Parameters:
dateTime- a dateTime as a string- Returns:
- the month extracted from the dateTime
-
monthInYear
public static double monthInYear(XPathContext context) throws XPathException
Return the month number from the current date.- Parameters:
context- the XPath dynamic context- Returns:
- the current month number
- Throws:
XPathException
-
monthName
public static java.lang.String monthName(java.lang.String date)
Return the month name from a date. The date must start with either "CCYY-MM" or "--MM"- Parameters:
date- the date/time as a string- Returns:
- the English month name, for example "January", "February"
-
monthName
public static java.lang.String monthName(XPathContext context) throws XPathException
Return the month name from the current date.- Parameters:
context- the XPath dynamic context- Returns:
- the English month name, for example "January", "February"
- Throws:
XPathException
-
monthAbbreviation
public static java.lang.String monthAbbreviation(java.lang.String date)
Return the month abbreviation from a date.- Parameters:
date- The date must start with either "CCYY-MM" or "--MM"- Returns:
- the English month abbreviation, for example "Jan", "Feb"
-
monthAbbreviation
public static java.lang.String monthAbbreviation(XPathContext context) throws XPathException
Return the month abbreviation from the current date.- Parameters:
context- the XPath dynamic context- Returns:
- the English month abbreviation, for example "Jan", "Feb"
- Throws:
XPathException
-
weekInYear
public static double weekInYear(java.lang.String dateTime)
Return the ISO week number of a specified date within the year (Note, this returns the ISO week number: the result in EXSLT is underspecified)- Parameters:
dateTime- the current date starting CCYY-MM-DD- Returns:
- the ISO week number
-
weekInYear
public static double weekInYear(XPathContext context) throws XPathException
Return the ISO week number of the current date- Parameters:
context- the XPath dynamic context (Note, this returns the ISO week number: the result in EXSLT is underspecified)- Returns:
- the ISO week number
- Throws:
XPathException
-
weekInMonth
public static double weekInMonth(java.lang.String dateTime)
Return the week number of a specified date within the month (Note, this function is underspecified in EXSLT)- Parameters:
dateTime- the date starting CCYY-MM-DD- Returns:
- the week number within the month
-
weekInMonth
public static double weekInMonth(XPathContext context) throws XPathException
Return the ISO week number of the current date within the month- Parameters:
context- the XPath dynamic context- Returns:
- the week number within the month
- Throws:
XPathException
-
dayInYear
public static double dayInYear(java.lang.String dateTime)
Return the day number of a specified date within the year- Parameters:
dateTime- the date starting with CCYY-MM-DD- Returns:
- the day number within the year, as a double
-
dayInYear
public static double dayInYear(XPathContext context) throws XPathException
Return the day number of the current date within the year- Parameters:
context- the XPath dynamic context- Returns:
- the day number within the year, as a double
- Throws:
XPathException
-
dayInMonth
public static double dayInMonth(java.lang.String dateTime)
Return the day number of a specified date within the month- Parameters:
dateTime- must start with CCYY-MM-DD, or --MM-DD, or ---DD- Returns:
- the day number within the month, as a double
-
dayInMonth
public static double dayInMonth(XPathContext context) throws XPathException
Return the day number of the current date within the month- Parameters:
context- the XPath dynamic context- Returns:
- the current day number, as a double
- Throws:
XPathException
-
dayOfWeekInMonth
public static double dayOfWeekInMonth(java.lang.String dateTime)
Return the day-of-the-week in a month of a date as a number (for example 3 for the 3rd Tuesday in May).- Parameters:
dateTime- must start with CCYY-MM-DD- Returns:
- the the day-of-the-week in a month of a date as a number (for example 3 for the 3rd Tuesday in May).
-
dayOfWeekInMonth
public static double dayOfWeekInMonth(XPathContext context) throws XPathException
Return the day-of-the-week in a month of the current date as a number (for example 3 for the 3rd Tuesday in May).- Parameters:
context- the XPath dynamic context- Returns:
- the the day-of-the-week in a month of the current date as a number (for example 3 for the 3rd Tuesday in May).
- Throws:
XPathException
-
dayInWeek
public static double dayInWeek(java.lang.String dateTime)
Return the day of the week given in a date as a number. The numbering of days of the week starts at 1 for Sunday, 2 for Monday and so on up to 7 for Saturday.- Parameters:
dateTime- must start with CCYY-MM-DD- Returns:
- the day of the week as a number
-
dayInWeek
public static double dayInWeek(XPathContext context) throws XPathException
Return the day of the week in the current date as a number. The numbering of days of the week starts at 1 for Sunday, 2 for Monday and so on up to 7 for Saturday.- Parameters:
context- the XPath dynamic context- Returns:
- the day of the week as a number
- Throws:
XPathException
-
dayName
public static java.lang.String dayName(java.lang.String dateTime)
Return the day of the week given in a date as an English day name: one of 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday' or 'Friday'.- Parameters:
dateTime- must start with CCYY-MM-DD- Returns:
- the English name of the day of the week
-
dayName
public static java.lang.String dayName(XPathContext context) throws XPathException
Return the day of the week given in the current date as an English day name: one of 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday' or 'Friday'.- Parameters:
context- the XPath dynamic context- Returns:
- the English name of the day of the week
- Throws:
XPathException
-
dayAbbreviation
public static java.lang.String dayAbbreviation(java.lang.String dateTime)
Return the day of the week given in a date as an English day abbreviation: one of 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', or 'Sat'.- Parameters:
dateTime- must start with CCYY-MM-DD- Returns:
- the English day abbreviation
-
dayAbbreviation
public static java.lang.String dayAbbreviation(XPathContext context) throws XPathException
Return the day of the week given in the current date as an English day abbreviation: one of 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', or 'Sat'.- Parameters:
context- the XPath dynamic context- Returns:
- the English day abbreviation
- Throws:
XPathException
-
hourInDay
public static double hourInDay(java.lang.String dateTime)
Return the hour of the day in the specified date or date/time- Parameters:
dateTime- must start with CCYY-MM-DDThh:mm:ss or hh:mm:ss- Returns:
- the hour
-
hourInDay
public static double hourInDay(XPathContext context) throws XPathException
Return the current hour of the day- Parameters:
context- the XPath dynamic context- Returns:
- the hour
- Throws:
XPathException
-
minuteInHour
public static double minuteInHour(java.lang.String dateTime)
Return the minute of the hour in the specified date or date/time- Parameters:
dateTime- must start with CCYY-MM-DDThh:mm:ss or hh:mm:ss- Returns:
- the minute
-
minuteInHour
public static double minuteInHour(XPathContext context) throws XPathException
Return the current minute of the hour- Parameters:
context- the XPath dynamic context- Returns:
- the minute
- Throws:
XPathException
-
secondInMinute
public static double secondInMinute(java.lang.String dateTime)
Return the second of the minute in the specified date or date/time- Parameters:
dateTime- must start with CCYY-MM-DDThh:mm:ss or hh:mm:ss- Returns:
- the second
-
secondInMinute
public static double secondInMinute(XPathContext context) throws XPathException
Return the current second of the minute- Parameters:
context- the XPath dynamic context- Returns:
- the second
- Throws:
XPathException
-
-