Results 1 to 4 of 4

Thread: Date

  1. #1
    asai is offline Senior Member
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    115
    Rep Power
    0

    Default Date

    Hi,

    I have a question about the date format.
    Here is my code:
    Java Code:
    private Date    transDate;
    and
    Java Code:
    transDate = yyyy.mm.dd;
    But there is something wrong with the date format.
    What is the correct format?

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,445
    Blog Entries
    7
    Rep Power
    20

    Default Re: Date

    Your second line doesn't make any sense; read the API documentation for the DateFormat and SimpleDateFormat classes.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    asai is offline Senior Member
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    115
    Rep Power
    0

    Default Re: Date

    I am not sure how this format is....
    Here is the hole file:

    Java Code:
    package Logikk.Business;
    
    import java.sql.Date;
    
    /**
     *
     * @author terje
     */
    public class LedgerTrans {
        
        private int     transID;
        private Date    transDate;
        private String  transText;
        private int  account;
        private double  debet;
        private double  credit; 
        
        public LedgerTrans()
        {
            transID = 0;
            transDate = dd.mm.yyyy; 
            transText = ""; 
            account = 0; 
            debet = 0;
            credit = 0;
        }
        
        public LedgerTrans(int number, String text, Date dato, int id, double debit, double kredit)
        {
            this.transID = id;
            this.account = number;
            this.transDate = dato;
            this.transText = text;
            this.debet = debit;
            this.credit = kredit; 
        }
    
        public int getid() {
            return transID;
        }
    
        public void setid(int id) {
            this.transID = id;
        }
    
        public int getaccount() {
            return account;
        }
    
        public void setaccount(int number) {
            this.account = number;
        }
    
        public String gettranstext() {
            return transText;
        }
    
        public void settranstext(String text) {
            this.transText = text;
        }
    
        public Double getdebet() {
            return debet;
        }
    
        public void setdebet(Double debit) {
            this.debet = debit;      
            
        }
        public Double getcredit() {
            return credit;
        }
    
        public void setcredit(Double kredit) {
            this.credit = kredit;      
            
        }
        public Date getdate() {
            return transDate;
        }
    
        public void setdate(Date dato) {
            this.transDate = dato;      
            
        }
    }

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Date

    Again, this:

    Java Code:
    transDate = dd.mm.yyyy;
    makes absolutely no sense whatsoever. You may wish to write a paragraph or two explaining what you're trying to do with this code and in particular this line of code. Also, why are you using java.sql.Date and not java.util.Date?

Similar Threads

  1. Replies: 5
    Last Post: 02-16-2012, 09:26 AM
  2. Replies: 4
    Last Post: 07-27-2011, 11:57 AM
  3. Replies: 2
    Last Post: 05-12-2011, 04:52 PM
  4. Compare date input to database with current date
    By hungleon88 in forum Advanced Java
    Replies: 2
    Last Post: 11-25-2008, 08:10 AM
  5. Creating a Gregorian Calendar using a Date object gives date - 1
    By prachi_goliwadekar in forum New To Java
    Replies: 1
    Last Post: 05-08-2008, 08:32 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
  •