aspose file tools*
The moose likes Java in General and the fly likes Calendar function to set date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Calendar function to set date" Watch "Calendar function to set date" New topic
Author

Calendar function to set date

sahana mithra
Ranch Hand

Joined: Oct 26, 2010
Posts: 72
class Employee
{
private Date doj;

public Employee (Date doj)
{
this.doj=doj;
}
public Date getDoj()
{
return doj;
}
}


class TestEmployeeSort
{
public static List<Employee> getEmployees()
{
List<Employee> col=new ArrayList<Employee>();
col.add(new Employee(new Date(1986,21,22));
}
}
In the above code i have used Date to set a date. I want to know how to use calendar function to do this. I know that i can use getInstance() and set the date. But I don't know how to implement it. Please help me to know how to set Date using Calendar function
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3097
    
  33

This might be useful: JavaDatesFaq


Mohamed Sanaulla | My Blog
Pawan Kr Gupta
Greenhorn

Joined: Nov 21, 2010
Posts: 26
Please use like this.

class Employee
{
private Date doj;

public Employee (Date doj)
{
this.doj=doj;
}
public Date getDoj()
{
return doj;
}
}



public class TestEmployeeSort
{
public static List getEmployees()
{
List col=new ArrayList();
col.add(new Employee(Calendar.getInstance().getTime()));
}
}
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14431
    
  23

Please UseCodeTags when you post source code.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calendar function to set date