实例 Java 显示当前日期与时间

x
 
import java.time.LocalDateTime;  // import the LocalDateTime class
public class Main {  
  public static void main(String[] args) {  
    LocalDateTime myObj = LocalDateTime.now();
    System.out.println(myObj);
  }  
}  
                    

输出结果

2025-03-15T06:13:04.465692