DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2005
    Posts
    44

    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!!

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    what date and time do you want to output?

  3. #3
    Join Date
    Nov 2005
    Posts
    44

    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??

  4. #4
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    look at the methods of java.text.DateFormat - you'll find the way to capture the current time and current date ...

  5. #5
    Join Date
    Nov 2005
    Posts
    2
    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

  1. query tuning
    By dhaya in forum Database
    Replies: 11
    Last Post: 08-25-2003, 05:24 PM
  2. Replies: 1
    Last Post: 08-06-2002, 09:20 AM
  3. Beta2 Southern Hemisphere Blues
    By Esmond Hart in forum .NET
    Replies: 2
    Last Post: 01-14-2002, 07:24 AM
  4. Date & Time
    By Randy in forum VB Classic
    Replies: 6
    Last Post: 04-18-2001, 01:49 PM
  5. Re: date / time picker
    By Tim Martin in forum VB Classic
    Replies: 3
    Last Post: 06-23-2000, 05:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links