I am trying to get today's date in format of yyyyMMdd
in groovy language.
I have tried to do this:
String oldDate = '20150702' Date date = Date.parse( 'yyyyMMdd', oldDate ) String currentDate = date.format( 'yyyyMMdd' )
Output: 20150702
I am trying to get today's date however.
public String format(String format, TimeZone tz)Create a String representation of this date according to the given format pattern and timezone. For example: def d = new Date(0) def tz = TimeZone. getTimeZone('GMT') println d. format('dd/MMM/yyyy', tz) would return the string "01/Jan/1970" .
Date previousDate = new Date() Date currentDate = new Date() previousDate. upto(currentDate) { it -> it-> represents date object. } currentDate. downto(previousDate) { it -> it-> represents date object. }
Then use:
new Date().format( 'yyyyMMdd' )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With