[Java] Class DateUtilStaticExtensions
- 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.
Methods Summary
Type Params | Return Type | Name and description |
---|---|---|
static Date |
parse(Date self, String format, String input) Parse a String into a Date instance using the given pattern. | |
static Date |
parse(Date self, String format, String input, TimeZone zone) 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. |
Inherited Methods Summary
Methods inherited from class | Name |
---|---|
class Object | wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Method Detail
public static Date parse(Date self, String format, String input)
Parse a String into a Date instance using the given pattern. This convenience method acts as a wrapper for SimpleDateFormat.
Note that a new SimpleDateFormat instance is created for every invocation of this method (for thread safety).
- throws:
- ParseException if there is a parse error
- Parameters:
-
self
- placeholder variable used by Groovy categories; ignored for default static methods -
format
- 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
- See Also:
- SimpleDateFormat.parse
- Since:
- 1.5.7
public static Date parse(Date self, String format, String input, TimeZone zone)
Parse a String into a Date instance using the given pattern and TimeZone. This convenience method acts as a wrapper for SimpleDateFormat.
Note that a new SimpleDateFormat instance is created for every invocation of this method (for thread safety).
- throws:
- ParseException if there is a parse error
- Parameters:
-
self
- placeholder variable used by Groovy categories; ignored for default static methods -
format
- pattern used to parse the input string. -
input
- String to be parsed to create the date instance -
zone
- TimeZone to use when parsing
- Returns:
- a new Date instance representing the parsed input string
- See Also:
- SimpleDateFormat.parse
- Since:
- 2.4.1
public 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. Sat for Saturdays). Such a string is generated by the toString method of Date
Note that a new SimpleDateFormat instance is created for every invocation of this method (for thread safety).
- throws:
- ParseException if there is a parse error
- Parameters:
-
self
- placeholder variable used by Groovy categories; ignored for default static methods -
dateToString
- 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
- Since:
- 1.8.4
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/2.5.14/html/gapi/org/apache/groovy/dateutil/extensions/DateUtilStaticExtensions.html