search
Login

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

1 vote
4.4k views
asked Sr Member 4.8k points 10 25 31

1 Answer

0 votes
These classes are used to the retrieve the data and time. In an application and use them accordingly.

import java.util.*;

class Datedemo{

public static void main(String[] args){ //getInstance() is a factory Method

Calender c = Calender.getInstance();

int date = c.get(Calender.DATE);

int month = c.get(Calender.MONTH);

int year = c.get(Calender.YEAR);

System.out.println(“Date:” +date+ “/” +(++month)+ ”/” +year);

int hour = c.get(Calender.Hour);

int minute = c.get(Calender.MINUTE);

int second = c.get(Calender.SECOND);

System.out.println(“Time =” +hour+ “:” +minute+ “:” +second);

Date d = new Date();

System.out.println(“Date:” + d);

          }

   }
answered Expert 15k points 15 23 30

Related questions

0 votes
1 answer 27 views
27 views
asked augustaina Sr Member 4.8k points 10 25 31
1 vote
1 answer 60 views
0 votes
1 answer 20 views
20 views
asked sara Guru 24.6k points 29 52 81
0 votes
1 answer 13 views
13 views
asked taye Sr Member 5k points 7 9 12
0 votes
1 answer 31 views
31 views
asked john Guru 27.1k points 31 50 97
...