Saturday, 3 June 2017

Java Program to display current date and time

Program to display current date and time in java:

Post By: Balwant Singh

package kuw_ord.test;
import java.util.*;
public class date
{
public static void main(String[] args)
{
Date bs=new Date();
System.out.println(bs.toString());

}

}
Date is the class in java that is available in java.util package. This class contains current date and time.In this program what basically doing is that i am creating the object of Date class that is bs. The object is created by using new keyword that allocate the memory to the bs object. After that the current object created is converted into String by using toString() method. It will create the date into String format.

The output of the program is:

Program-to-display-current-date-and-time
FIG: Output displaying current date and time


No comments:

Post a Comment

AWS Migration Guide: Complete Cloud Migration Strategy for Businesses

Amazon ECS Complete Guide: AWS Elastic Container Service Explained

Amazon ECS Complete Guide: AWS Elastic Container Service Explained Amazon ECS Complete Guide: AWS Elastic Container ...