zade
zade

Reputation: 165

Change the time of a date

If I use

new Date()

it returns me date with time stamp of the current time. How can I change the date appended with the date?

Upvotes: 0

Views: 1489

Answers (1)

aiolos
aiolos

Reputation: 4697

You coudl use the set method to modify your date instance:

def date = new Date()
date.set(second: 0, minute: 0, hourOfDay: 15)

If you don't need any time you could also use clearTime() to remove the time portion of your date.

Upvotes: 4

Related Questions