Get Current Date using Java
In this tutorial, I am attaching simple about, How to Get Current Date using Java. The example has been tested and output is shared in the post.
CurrentDateExample1.java
package com.dineshkrish.date; import java.util.Date; public class CurrentDateExample1 { public static void main(String[] args) { // Defining Date Object Date date = new Date(); System.out.println(date); } }
CurrentDateExample2.java
package com.dineshkrish.date; import java.util.Calendar; import java.util.Date; public class CurrentDateExample2 { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); Date date = calendar.getTime(); System.out.println(date); } }
CurrentDateExample3.java
package com.dineshkrish.date; import java.util.Date; public class CurrentDateExample3 { public static void main(String[] args) { long millSecond = System.currentTimeMillis(); Date date = new Date(millSecond); System.out.println(date); } }
Output
——————
Sat Nov 19 17:58:52 IST 2016
References
More from my site

Hello, folks, I am a founder of idineshkrishnan.com. I love open source technologies, If you find my tutorials are useful, please consider making donations to these charities.
No responses yet