print current date in java

后端 未结 9 1803
半阙折子戏
半阙折子戏 2020-12-18 19:38

I want to print current date and time in java..This is the code I am trying from a java tutorial:

import java.util.*;
  
public class Date {
   public static          


        
9条回答
  •  春和景丽
    2020-12-18 20:15

    You could keep the code as simple as ::

    import java.util.*;
    public class Today{
      public static void main(String args[]){
        System.out.println("System Date :: ");
        System.out.println(new Date());
      }
    }
    

    As well as change the class name to today or something else but not Date as it is a keyword

提交回复
热议问题