Class 2 Exam  >  Class 2 Videos  >  Mathematics for Class 2  >  Time and Calendar

Time and Calendar Video Lecture | Mathematics for Class 2

14 videos|58 docs|19 tests

Top Courses for Class 2

FAQs on Time and Calendar Video Lecture - Mathematics for Class 2

1. How can I create a new instance of the Time class in Java?
Ans. To create a new instance of the Time class in Java, you can use the following code: ```java Time currentTime = new Time(); ``` This will create a new instance of the Time class with the current time.
2. How can I add or subtract time in Java using the Time class?
Ans. You can add or subtract time in Java using the Time class by using the `addTime()` and `subtractTime()` methods. For example: ```java currentTime.addTime(5); // Adds 5 minutes to the current time currentTime.subtractTime(2); // Subtracts 2 minutes from the current time ```
3. How can I convert a Time object to a Calendar object in Java?
Ans. To convert a Time object to a Calendar object in Java, you can use the following code: ```java Calendar calendar = Calendar.getInstance(); calendar.setTime(currentTime); ``` This will convert the Time object `currentTime` to a Calendar object `calendar`.
4. How can I get the current date and time using the Calendar class in Java?
Ans. You can get the current date and time using the Calendar class in Java by using the following code: ```java Calendar currentDateTime = Calendar.getInstance(); ``` This will create a new Calendar object `currentDateTime` with the current date and time.
5. How can I format the date and time in a specific way using the Calendar class in Java?
Ans. You can format the date and time in a specific way using the Calendar class in Java by using the `SimpleDateFormat` class. For example: ```java SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); String formattedDateTime = sdf.format(currentDateTime.getTime()); System.out.println(formattedDateTime); ``` This will format the date and time in the `currentDateTime` object according to the specified pattern "dd/MM/yyyy HH:mm:ss".
14 videos|58 docs|19 tests
Explore Courses for Class 2 exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Semester Notes

,

practice quizzes

,

study material

,

pdf

,

Time and Calendar Video Lecture | Mathematics for Class 2

,

MCQs

,

Exam

,

ppt

,

Important questions

,

video lectures

,

Time and Calendar Video Lecture | Mathematics for Class 2

,

Objective type Questions

,

Summary

,

Time and Calendar Video Lecture | Mathematics for Class 2

,

Viva Questions

,

mock tests for examination

,

Free

,

Sample Paper

,

Extra Questions

,

shortcuts and tricks

,

past year papers

,

Previous Year Questions with Solutions

;