Below is a simple Java program to return the data and time of the current system that this code runs on.
More like this:
- How to Get Operating System Name using Java
- Examples of ArrayList in Java
- Print Prime Numbers from 1 to N in Java
To get started, you will need to import the Date Utility library:
import java.util.Date;
Get current system date and time using Java
import java.util.Date; public class GetCurrentDateTime { public static void main(String args[]) { Date date = new Date(); System.out.print(date.toString()); } }
Output
Fri Sep 24 02:53:01 GMT 2021
Happy coding!