How to display the system time in Java

2 Answers

0 votes
public class MyClass {
    public static void main(String args[]) {
		System.out.format("%tc", System.currentTimeMillis());
    }
}




/*
run:

Sat Aug 07 09:42:12 GMT 2021

*/

 



answered Aug 7, 2021 by avibootz
edited Aug 7, 2021 by avibootz
0 votes
import java.util.Date;

public class MyClass {
    public static void main(String args[]) {
		System.out.printf("%tc", new Date());
    }
}




/*
run:

Sat Aug 07 09:43:45 GMT 2021

*/

 



answered Aug 7, 2021 by avibootz

Related questions

2 answers 281 views
1 answer 201 views
1 answer 193 views
1 answer 294 views
1 answer 248 views
...