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);
    }
}

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.