Java Date and time Homework Help
Previous
Next
Java Date and time:
In java the date class is available it is used to capture current date and time. This class supports following constructors.
1. date() – to initialize current date and time
2. date(long millisec) – it accepts number milliseconds since midnight
Example :
{`public class sample { ; public static void main(String args[]) { ; Date newdate = new Date(); // display time and date System.out.println(date.toString()); } ; } ; `}
Output:
On June 30 08:45:06
Date comparison;
In java using date class we will compare the date in three ways.
Using getTime() method we can obtain number of milliseconds since midnight
Using before (), after (), and equals () method compare before any particular date or after or two date are equal.
Using compareTo() method we can compare two dates.
Java Tutorials
- Environment setup
- Basic concept
- Object Classes
- Constructors
- OOPS in java
- data abstraction
- Variable Types
- Modifiers
- Operators
- Loop Controls
- Decision Making
- Strings
- Arrays
- Date and Time
- Methods in java
Java sample assignments
Programming Topics
- Ada
- Assembly Language
- AutoCAD
- BASIC
- Computer virus
- C Programming
- Euphoria
- Fortran Homework Help
- Game programming language
- Java Assignment Help
- JavaScript
- Java Servlets Help
- Machine Language
- Matlab
- Pascal
- Perl
- PHP
- Python
- Ruby
- Servlet Life Cycle
- Smalltalk
- SOAP
- Visual Basic
- COBOL
- Lisp
- Logo Help
- Plankalkul Help
- Prolog
- REBOL
- Rexx
- Scheme Help
- TCL
- ToonTalk Help