LocalDateTime is a date-time without a time-zone , such as 2007-12-03T10:15:30. It’s an immutable object that represents date and time in the format “ year - month - day - hour - minute - second”.

Getting Current Date And Time In The Format “YYYY-MM-DD HH:MM:SS” .

For cases, where you need both current date and current time, use LocalDateTime class and call toString() method on it’s object. As this class is final , call it’s factory method now() to get an instance. i.e LocalDateTime.now().toString(). Find the code below.