's that I'm trying to convert to strings with the format of
yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
My code seems to work in most cases BUT according to crashlytics... it's sometimes giving me dates that don't exist. Like weirdly large year values or just dates that don't exist like April 31st, even though april only has 30 days.
I think it maybe is coming from the fact that I use SimpleDateFormat. Does that sound like something that could be the fault of SDF?
c
Casey Brooks
06/02/2024, 5:14 PM
SDF is infamously not thread-safe. If you're not synchronizing access to the SDF object or using a new instance every time you're formatting a date, you're likely seeing the result of race conditions https://www.baeldung.com/java-simple-date-format#2-thread-safety
c
Colton Idle
06/02/2024, 5:17 PM
I saw that SDF isn't thread safe and maybe I need to brush up on threading and stuff. but im not sure how that could be the cause here. Each time I do the conversion I create a new SDF instance.
Colton Idle
06/02/2024, 5:17 PM
would love to be taught how that could still go wrong, because i dont see anything obvoisly wrong with going this route.