Hi its me again, i am having a error about LocalDate.now() in my fileManager Class. im not sure whats the problem.
ive listed the Screen shot of my error, code and the varibles in my other Activity class.
The classes are in different Directores but in same folder. idk whats the cause of it. If anyone can help that would be appreciated.
#Having a unknown error LocalDate.now()
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
well it seems like you have to pass a string but you pass a LocalDate
and like the error Message says, it can not convert a LocalDate to a string
so what should i do then?
pass a String
no
oh 😭
you can use a DateTimeFormatter and create a format and then date.format(formatter). or .toString() then you get the ISO-format
and cast are done like this (String). not by just writing the type in front of it
im new to java and ill try the datatimeformatter rn
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
LocalDate date = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
String now = date.format(formatter);
System.out.println(now);
Detected code, here are some useful tools:
System out
16.12.2024
case "SWM-01":
LocalDateTime currentDateTime = LocalDateTime.parse("2024-12-16T21:14:31Z", DateTimeFormatter.ISO_DATE_TIME);
return new Activity(code, "Scuba Diving",
"Experience the underwater world",
currentDateTime.plusDays(7),
120, true, 6000);
this?
you coded the constructor that needs a string
if you want a LocalDate then change the constructor
Ok let me try remove string from constructor
no replace it with a LocalDate
i think i fixed it
DOes this look alright?
left is my constructor and right is the method
it is showing no errors now
👍
thanks man