-
Adding date and time to a class?
Hi,
I'm currently writing a number of classes to handle video loans etc. The current class, called 'Loans', handles simple information about a loan of a video to a borrower.
My question is simply how do I add the date and time to this class so it is represented with the loan information for a borrower?
My code for this class is currently as follows,
Code:
package videos;
import simplejava.*;
public class Loan {
private Borrower borrower;
private Video video;
public Loan() {
this.video = video;
this.borrower = borrower;
}
public String toString() {
return video + "" + borrower;
}
}
Basically, when I call the toString method I need to be able to print out the date and time as well. Any help really appreciated!!
-
what date and time do you want to output?
-
Re: Adding date and time to a class?
Hi,
Thanks for the reply. I want to be able to add the date and time when the video rental period began, so the current time when the video was rented.
Any ideas??
-
look at the methods of java.text.DateFormat - you'll find the way to capture the current time and current date ...
-
Here's an example of how to get current Date and Time:
http://www.javadb.com/?ex=NDM1NDU2MF...NjY4NDE1OTI%3D
Hope it helps...
Javaman
Similar Threads
-
By dhaya in forum Database
Replies: 11
Last Post: 08-25-2003, 05:24 PM
-
By Gill in forum VB Classic
Replies: 1
Last Post: 08-06-2002, 09:20 AM
-
By Esmond Hart in forum .NET
Replies: 2
Last Post: 01-14-2002, 07:24 AM
-
By Randy in forum VB Classic
Replies: 6
Last Post: 04-18-2001, 01:49 PM
-
By Tim Martin in forum VB Classic
Replies: 3
Last Post: 06-23-2000, 05:16 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|