print current date in java

后端 未结 9 1773
半阙折子戏
半阙折子戏 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:32

    import java.util.Date;
    public class Dte {
    
        public static void main(String[] args) {
            Date date = new Date();
            System.out.println(date.toString());
        }
    }
    

    Change the class name Date to Dte or some thing and the code will work properly.

    The output is : Mon Nov 03 21:27:15 IST 2014

提交回复
热议问题