askIT

Print date and time

Lagre Download print_date_and_time

Calling LocalDateTime.now() will give you representations for the current date and time.

package com.nettport.coffeshop;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Main {

    public static void main(String[] args) {
        // 2018/05/01 12:09:05
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println(dtf.format(localDateTime));
    }
}

Output:

2018/05/01 12:09:05

Add comment

avatar_blank_60.png

Comment:

Name:

Email:

Comments

No comments yet. You can be the first one to comment. Just write your comment in the form and click on the submit button.