Class DateUtilStaticExtensions
java.lang.Object
org.apache.groovy.dateutil.extensions.DateUtilStaticExtensions
This class defines new groovy static methods which appear on normal JDK
Date and Calendar classes inside the Groovy environment.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Date
Parse a String into a Date instance using the given pattern.static Date
Parse a String into a Date instance using the given pattern and TimeZone.static Date
parseToStringDate
(Date self, String dateToString) Parse a String matching the pattern EEE MMM dd HH:mm:ss zzz yyyy containing US-locale-constants only (e.g.
-
Constructor Details
-
DateUtilStaticExtensions
public DateUtilStaticExtensions()
-
-
Method Details
-
parse
Parse a String into a Date instance using the given pattern. This convenience method acts as a wrapper forSimpleDateFormat
.Note that a new SimpleDateFormat instance is created for every invocation of this method (for thread safety).
- Parameters:
self
- placeholder variable used by Groovy categories; ignored for default static methodsformat
- pattern used to parse the input string.input
- String to be parsed to create the date instance- Returns:
- a new Date instance representing the parsed input string
- Throws:
ParseException
- if there is a parse error- Since:
- 1.5.7
- See Also:
-
parse
public static Date parse(Date self, String format, String input, TimeZone zone) throws ParseException Parse a String into a Date instance using the given pattern and TimeZone. This convenience method acts as a wrapper forSimpleDateFormat
.Note that a new SimpleDateFormat instance is created for every invocation of this method (for thread safety).
- Parameters:
self
- placeholder variable used by Groovy categories; ignored for default static methodsformat
- pattern used to parse the input string.input
- String to be parsed to create the date instancezone
- TimeZone to use when parsing- Returns:
- a new Date instance representing the parsed input string
- Throws:
ParseException
- if there is a parse error- Since:
- 2.4.1
- See Also:
-
parseToStringDate
Parse a String matching the pattern EEE MMM dd HH:mm:ss zzz yyyy containing US-locale-constants only (e.g. Sat for Saturdays). Such a string is generated by the toString method ofDate
Note that a new SimpleDateFormat instance is created for every invocation of this method (for thread safety).
- Parameters:
self
- placeholder variable used by Groovy categories; ignored for default static methodsdateToString
- String to be parsed to create the date instance. Must match the pattern EEE MMM dd HH:mm:ss zzz yyyy with US-locale symbols- Returns:
- a new Date instance representing the parsed input string
- Throws:
ParseException
- if there is a parse error- Since:
- 1.8.4
-