Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Date;
- @SuppressWarnings( "deprecation" ) //Date API was deprecated. But its safe to use it for small apps...
- class DateDemo
- {
- public static void main(String arg[])
- {
- Date currentDate=new Date(); //Assigns Current Date to DateObject
- int date,month,year,minutes,hours;
- //You can use below variables to initialize object of your custom Date class with Current Date!
- date=currentDate.getDate(); //get Date from currentDate
- month=currentDate.getMonth()+1; //get Month (starts with 0) from currentDate
- year=currentDate.getYear()+1900; //get Year (from year 1900) from currentDate
- minutes=currentDate.getMinutes(); //get Minutes from currentDate
- hours=currentDate.getHours(); //get Hours from currentDate
- System.out.println("Current Date: \n"+ date+"-"+month+"-"+year+" "+hours+":"+minutes);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement