Developer community
+1 vote
4.4k views
asked by Sr Member (4.8k points) 10 23 31 | 4.4k views

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 by Expert (15k points) 15 23 29

Related questions

0 votes
1 answer
asked by augustaina Sr Member (4.8k points) 10 23 31 | 26 views
+1 vote
1 answer
0 votes
1 answer
asked by sara Guru (24.6k points) 29 51 77 | 18 views
0 votes
1 answer
asked by taye Sr Member (5k points) 7 9 12 | 12 views
0 votes
1 answer
asked by john Guru (27.1k points) 31 48 96 | 29 views
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

Categories


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

3.8k questions

4k answers

117 comments

10.7k users

3,751 questions
4,046 answers
117 comments
10,709 users