org.mmbase.bridge.util.xml
Class DateFormat

java.lang.Object
  extended byorg.mmbase.bridge.util.xml.DateFormat

public class DateFormat
extends Object

Dates are stored as integer in mmbase. If you want to show these dates in a nice format in the XSL transformation. it is necessary to use this Xalan extension. The XSLT looks like this then:

  <xsl:stylesheet  version = "1.0"
    xmlns:xsl ="http://www.w3.org/1999/XSL/Transform"
    xmlns:date ="org.mmbase.bridge.util.xml.DateFormat"
  >
 

Since:
MMBase-1.7
Version:
$Id: DateFormat.java,v 1.14 2005/10/07 18:47:41 michiel Exp $
Author:
Nico Klasens, Martijn Houtman, Michiel Meeuwissen

Constructor Summary
DateFormat()
           
 
Method Summary
static String format(Cloud cloud, Node node, String fieldName, String pattern, String timeZone)
          Deprecated. not sure where this is used?
static String format(Cloud cloud, String number, String fieldName, String pattern, String timeZone)
          Formats a node's field value with the date pattern
protected static String format(String fieldValue, String pattern, int factor, String timeZone, Locale locale)
           
static String format(String fieldValue, String pattern, int factor, String timeZone, String language, String country)
          Formats the fieldvalue to a date pattern
static String format(String fieldValue, String pattern, String timeZone, String language, String country)
          Formats the fieldvalue to a date pattern
static String format(String number, String fieldName, String pattern, String timeZone, String language, String country)
          Formats a node's field value with the date pattern
static String format(String cloudName, String number, String fieldName, String pattern, String timeZone, String language, String country)
          Formats a node's field value with the date pattern
static int getDatePart(String fieldValue, int factor, int datePart)
          Returns the a part of the date
static int getDatePart(String fieldValue, int factor, int datePart, String timeZone)
          Returns the a part of the date
static int getDay(String fieldValue)
          Returns the day of the month part of the date
static int getDay(String fieldValue, String timeZone)
          Returns the day of the month part of the date
static int getHours(String fieldValue)
          Returns the hours part of the date
static int getHours(String fieldValue, String timeZone)
          Returns the hours part of the date
static int getMinutes(String fieldValue)
          Returns the minutes part of the date
static int getMinutes(String fieldValue, String timeZone)
          Returns the minutes part of the date
static int getMonth(String fieldValue)
          Returns the month part of the date
static int getMonth(String fieldValue, String timeZone)
          Returns the month part of the date
static int getSeconds(String fieldValue)
          Returns the seconds part of the date
static int getSeconds(String fieldValue, String timeZone)
          Returns the seconds part of the date
static int getYear(String fieldValue)
          Returns the year part of the date
static int getYear(String fieldValue, String timeZone)
          Returns the year part of the date
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateFormat

public DateFormat()
Method Detail

format

public static String format(String number,
                            String fieldName,
                            String pattern,
                            String timeZone,
                            String language,
                            String country)
Formats a node's field value with the date pattern

Parameters:
number - the number or alias of the node containing the field
fieldName - the name of the field to format
pattern - the date pattern (i.e. 'dd-MM-yyyy')
timeZone - timezone of the field value
language - Language of the field value
country - country of the field value
Returns:
the formatted string

format

public static String format(String cloudName,
                            String number,
                            String fieldName,
                            String pattern,
                            String timeZone,
                            String language,
                            String country)
Formats a node's field value with the date pattern

Parameters:
cloudName - the name of the cloud in which to find the node
number - the number or alias of the node containing the field
fieldName - the name of the field to format
pattern - the date pattern (i.e. 'dd-MM-yyyy')
timeZone - timezone of the field value
language - Language of the field value
country - country of the field value
Returns:
the formatted string

format

public static String format(Cloud cloud,
                            String number,
                            String fieldName,
                            String pattern,
                            String timeZone)
Formats a node's field value with the date pattern

Parameters:
cloud - the cloud in which to find the node
number - the number or alias of the node containing the field
fieldName - the name of the field to format
pattern - the date pattern (i.e. 'dd-MM-yyyy')
timeZone - timezone of the field value
Returns:
the formatted string

format

public static String format(String fieldValue,
                            String pattern,
                            String timeZone,
                            String language,
                            String country)
Formats the fieldvalue to a date pattern

Parameters:
fieldValue - time-stamp in seconds
pattern - the date pattern (i.e. 'dd-MM-yyyy')
timeZone - timezone of the field value
language - Language of the field value
country - country of the field value
Returns:
the formatted string

format

public static String format(String fieldValue,
                            String pattern,
                            int factor,
                            String timeZone,
                            String language,
                            String country)
Formats the fieldvalue to a date pattern

Parameters:
fieldValue - time-stamp
pattern - the date pattern (i.e. 'dd-MM-yyyy')
factor - Factor to multiply fieldvalue to make milliseconds. Should be 1000 normally (so field in seconds)
timeZone - Timezone. Null or blank means server timezone. If not recognized it will fall back to GMT.
language - The language for which the date must be formatted.
country - The country for which the date must be formatted.
Returns:
the formatted string

format

protected static String format(String fieldValue,
                               String pattern,
                               int factor,
                               String timeZone,
                               Locale locale)
Parameters:
fieldValue - time-stamp
pattern - the date pattern (i.e. 'dd-MM-yyyy')
factor - Factor to multiply fieldvalue to make milliseconds. Should be 1000 normally (so field in seconds)
timeZone - Timezone. Null or blank means server timezone. If not recognized it will fall back to GMT.
locale - The locale for which the date must be formatted.
Returns:
the formatted String

format

public static String format(Cloud cloud,
                            Node node,
                            String fieldName,
                            String pattern,
                            String timeZone)
                     throws TransformerException
Deprecated. not sure where this is used?

Formats a node's field value with the date pattern. This version requires you to supply a DOM node. It will search for a tag of the form <field name='number' > and uses it's contents to retrieve the node.

Parameters:
cloud - the cloud in which to find the node
node - A DOM node (xml) containing the node's fields as subtags
fieldName - the name of the field to format
pattern - the date pattern (i.e. 'dd-MM-yyyy')
timeZone - The timezone of the field value
Returns:
the formatted string
Throws:
TransformerException - if something went wrong while searching the DOM Node

getYear

public static int getYear(String fieldValue)
Returns the year part of the date

Parameters:
fieldValue - time-stamp
Returns:
year part

getMonth

public static int getMonth(String fieldValue)
Returns the month part of the date

Parameters:
fieldValue - time-stamp
Returns:
month part

getDay

public static int getDay(String fieldValue)
Returns the day of the month part of the date

Parameters:
fieldValue - time-stamp
Returns:
day of the month part

getHours

public static int getHours(String fieldValue)
Returns the hours part of the date

Parameters:
fieldValue - time-stamp
Returns:
hours part

getMinutes

public static int getMinutes(String fieldValue)
Returns the minutes part of the date

Parameters:
fieldValue - time-stamp
Returns:
minutes part

getSeconds

public static int getSeconds(String fieldValue)
Returns the seconds part of the date

Parameters:
fieldValue - time-stamp
Returns:
seconds part

getYear

public static int getYear(String fieldValue,
                          String timeZone)
Returns the year part of the date

Parameters:
fieldValue - time-stamp
timeZone - timezone
Returns:
year part

getMonth

public static int getMonth(String fieldValue,
                           String timeZone)
Returns the month part of the date

Parameters:
fieldValue - time-stamp
timeZone - timezone
Returns:
month part

getDay

public static int getDay(String fieldValue,
                         String timeZone)
Returns the day of the month part of the date

Parameters:
fieldValue - time-stamp
timeZone - timezone
Returns:
day of the month part

getHours

public static int getHours(String fieldValue,
                           String timeZone)
Returns the hours part of the date

Parameters:
fieldValue - time-stamp
timeZone - timezone
Returns:
hours part

getMinutes

public static int getMinutes(String fieldValue,
                             String timeZone)
Returns the minutes part of the date

Parameters:
fieldValue - time-stamp
timeZone - timezone
Returns:
minutes part

getSeconds

public static int getSeconds(String fieldValue,
                             String timeZone)
Returns the seconds part of the date

Parameters:
fieldValue - time-stamp
timeZone - timezone
Returns:
seconds part

getDatePart

public static int getDatePart(String fieldValue,
                              int factor,
                              int datePart)
Returns the a part of the date

Parameters:
fieldValue - time-stamp
factor - Factor to multiply fieldvalue to make milliseconds. Should be 1000 normally (so field in seconds)
datePart - which part of the date should be returned. These are Calendar constants
Returns:
a part

getDatePart

public static int getDatePart(String fieldValue,
                              int factor,
                              int datePart,
                              String timeZone)
Returns the a part of the date

Parameters:
fieldValue - time-stamp
factor - Factor to multiply fieldvalue to make milliseconds. Should be 1000 normally (so field in seconds)
datePart - which part of the date should be returned. These are Calendar constants
timeZone - Timezone. Null or blank means server timezone. If not recognized it will fall back to GMT.
Returns:
a part


MMBase build 1.8.1.20060716