Fix try catch
Pls hepl me fix that
try {
LocalDateTime today = LocalDateTime.parse(events.getFirst(), DateTimeFormatter.ofPattern(dft));
System.out.println("--- Statistics ---");
System.out.println("Total events: " + events.size());
System.out.println("Events today: " + today.format(date));
System.out.println("First Event: " + events.get(0));
} catch (DateTimeException e){
System.out.println("Error date formatting: " + e.getMessage());
}
13 Replies
⌛ This post has been reserved for your question.
Hey @Dexter! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
well whats the problem
Not print Events
Error date formatting: Text 'g 26/11/2025 18:25' could not be parsed at index 0
I can give full code
import java.io.*;
import java.time.DateTimeException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Scanner;
This message has been formatted automatically. You can disable this using
/preferences.pls help fix because i dont know how fix it i asced gemini,gpt and grok but nothing
Event: пвап 26/11/2025 19:40
Error date formatting: Text 'g 26/11/2025 18:25' could not be parsed at index 0
(print)
Well there is a line in your
events.txt which does not conform to your datetime formatter pattern.There seems to be an exception that ignores this, did I write it or is something wrong?
Yes, it tries to parse the first line of the file, fails, and logs the error message.
I just don't know what to do anymore, it doesn't work, the AI doesn't help, it just writes nonsense
The problem is that you store
[event name] [event date] in the file but try to parse the whole line as the date.
So you need to extract the date from the line again.
Since your date is always 16 characters long, you could substring the last 16 characters from the line.
Ah and DateTimeFormatter.ofPattern(dft) is wrong. dft is not a pattern but the formatted today.thanks
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@1206629348526788638>.