954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to write date

I made a program and want to enter previous dates into a linkedList. My code is

package bowlinggame;

import java.util.Date;
import java.util.LinkedList;
import java.util.TreeSet;

public class BowlingGame {   
    
    public static void main(String[] args) 
    {
        TreeSet <String>PlayerNames = new TreeSet<String>();
        PlayerNames.add("Steve");
        PlayerNames.add("James");
        PlayerNames.add("Bob");
        for (Object o : PlayerNames) 
        {
            System.out.println(o);
        }
        LinkedList <Date>SteveDate = new LinkedList<Date>();// Enter the dates here just like scores
        LinkedList <Integer>SteveScore = new LinkedList<Integer>();
        SteveScore.add(205);
        SteveScore.add(240);
        SteveScore.add(189);
        System.out.println("Steve's last score is " + SteveScore.getLast() + " and the last time he played was " + SteveDate);
    }
}
vishal1949
Light Poster
42 posts since Jul 2011
Reputation Points: 21
Solved Threads: 1
 

Have a look at the SimpleDateFormat class. You will find it has methods to convert (parse) Strings in various formats into Dates that you can add to your list.

JamesCherrill
Posting Genius
Moderator
6,371 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: