Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using Date object with constructor

Status
Not open for further replies.

MarkJ2

Technical User
Sep 25, 2001
17
US
In the program I am writing, I would like to create an instance of an object that will allow anyone to pass in a date (year,month,date,hour,minutes) as a Date object.

I am able to create an instance of an object that takes the parameters of year,month, and date and passes them to another constructor, but I am not sure how to do what I am describing in my first paragraph.

Thanks,

Mark
 
hi

i'm not sure if there is a constructor to accept date object but there's a foolproof method. in ur own constructor, accept a date object. then inside the constructor get the hours, mins, secs whatever and pass it to the consructot of original date object.

class mydate extends Date
{
public mydate(Date d)
{
super(d.getHours(),d.getMinutes(),...);
}
}

then create an instance with ur own class

mydate d = new mydate(dateobject);


catch my point?

luv
Karthik.
Pearls and Diamonds are not found on surfaces.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top