Package org.apache.tools.ant.taskdefs
Class Tstamp
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.Tstamp
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
This nested element that allows a property to be set to the current date and time in a given format.static class
set of valid units to use for time offsets. -
Field Summary
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreate a custom format with the current prefix.void
execute()
create the timestamps.protected Date
getNow()
Return theDate
instance to use as base for DSTAMP, TSTAMP and TODAY.Checks and returns a Date if the specified property is set.void
Set a prefix for the properties.Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
-
Constructor Details
-
Tstamp
public Tstamp()
-
-
Method Details
-
setPrefix
Set a prefix for the properties. If the prefix does not end with a "." one is automatically added.- Parameters:
prefix
- the prefix to use.- Since:
- Ant 1.5
-
execute
create the timestamps. Custom ones are done before the standard ones, to get their retaliation in early.- Overrides:
execute
in classTask
- Throws:
BuildException
- on error.
-
createFormat
create a custom format with the current prefix.- Returns:
- a ready to fill-in format
-
getNow
-
getNow
protected Optional<Date> getNow(String propertyName, Function<String, Date> map, BiFunction<String, String, String> log) Checks and returns a Date if the specified property is set.- Parameters:
propertyName
- name of the property to checkmap
- conversion of the property value as string to Datelog
- supplier of the log message containing the property name and value if the conversion fails- Returns:
- Optional containing the Date or null
-