This Example shows you how to display date and time velocity. The methods used in this example are described below:-
1:- Initialize velocity run
engine through method init().
2:- Create object of VelocityContext Class.
3:- Create Template class object, Template class object is used for controlling template methods and properties.
template.merge(context, writer): Merge method of the Template class is used here for merging the VelocityContext class objects to produce the output. Template class object is used for controlling template methods and properties.
Date date = cal.getTime(): Here we created Date class object by using Calender class object.
$date.getHours(), $date.getMinutes(), $date.getSeconds(): getHours() is used here to print hours, getMinutes() is used here to print minutes, getSeconds() is used here to print seconds.$date.getDate(), $date.getMonth(), $date.getYear(): getDate() is used here to print date, getMonth() is used here to print month, getYear() is used here to print year.
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: Date Tool Example
Post your Comment