I've searched multiple posts and can't find something specific for my needs.
** The goal**
I need to take a user input in the form of Date and then a String description and store it in an Arraylist.
i.e 10 Nov 2021, Clean my room
I want my date to be in D MMM YYYY format
Once this is stored in the arraylist, I need to be able to search the arraylist of tasks for the current date
If my arraylist contains a task for 11 Nov 2021 and current date/local machine date is 11 Nov 2021, I need to print the task for today , else print out that no tasks exist for the current date.
Here is a snippet of what I've tried so far
public class TestClass {
public static void main(String[]args){
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try{
System.out.println("Enter : ");
// sample string
String str = br.readLine();
List<String> list = Arrays.asList(str.split(","));
System.out.println("--------------");
System.out.println(list);
}
catch(IOException e){
System.out.println(e);
}
}
}
Here is an output
Enter :
10 jan 2020, clean room
--------------
[10 jan 2020, clean room]
I'm not sure how to proceed next, thanks in advance.
Taskor something else appropriate. Then you can create an array list of instances of the class.Taskclass. You will find many examples of how to split a string at the first comma (or other predefined character). Many examples of how to parse a date string into aLocalDate(only avoid example using the troublesome and long outdatedSimpleDateFormatandDateclasses).