import java.text.SimpleDateFormat;
import java.util.Date;
public class GetDateMethod {
public static void main(String[] args) {
Date obDate = new Date();
SimpleDateFormat obDateFormat = new SimpleDateFormat("yyyy-MM-dd");
System.out.println("Current Date of system :"
+ obDateFormat.format(obDate.getTime()));
System.out.println("Day of given date : " + obDate.getDay());
}
}
Output
Current Date of system :2010-11-25 04:11:25 PM
Hours of given date : 4
---------------------------------
// da-getDay1.jsl
// Date.getDay example
import java.util.*;
public class MyClass
{
public static void main(String[] args)
{
// Construct a date object:
Date d = new Date("11-Dec-1314");
// Get the day number:
System.out.println("Date part in 11-Dec-1314 is: " +
d.getDay());
}
}
/*
Output:
Date part in 11-Dec-1314 is: 11
*/
No comments:
Post a Comment