So the string date of ' 00:00:00' will now appear as 'Tue Dec 11 00:00:'. This code given these two parameters will return a object and will have the Default formatting of 'E MMM dd HH:mm:ss z yyyy'. Note: This format does not change how your string date is output, it simply gives parse the correct context (format) of what you are attempting to parse with it. Pass the parse function the format of your input and your date as a string. Date.parse(String format, String dateInput) Parsing a string date is simple and works like this. Date.parse() is a static method and can be directly called from anywhere without instantiating a date object. So lets take a look at exactly how this is working (This is more an exercise in me remembering). This particular Date.parse(String format, String input) acts as a wrapper for SimpleDateFormat. This works because almost everything that works in java will work in groovy since groovy is extension of java. This makes use of the package and is one of many extensions in groovy to java. How to actually change the format of a string date in Groovy:Īfter many failed attempts to correctly change the format of a string date in groovy I finally figured out how to do this properly.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |