I feel like the solution is very simple but I am right now staring at it for 10 Minutes and i cannot find any errors in my code. Seriously.
Whereas eventDateStart
is an integer. Integer normally do take 8 characters for string to int
conversions and i don't see why Java cannot converse it I am like ... ugh??
Code is producing NumberFormatException:
String rruleMonthday = "-1";
//where ar rrule is sth like --> RRULE:FREQ=MONTHLY;BYMONTHDAY=29
int firstMonthday = (rrule.indexOf("BYMONTHDAY=") + 11);
try {
rruleMonthday = rrule.substring(firstMonthday, rrule.indexOf(";", firstMonthday));
} catch (Exception ex) {
rruleMonthday = rrule.substring(firstMonthday, rrule.indexOf("\n", firstMonthday));
}
eventDateStart = eventDateStart.substring(0, 6) + rruleMonthday;
System.out.println("eventDateStart: ." + eventDateStart + ".");
System.out.println("2: " + Integer.parseInt(eventDateStart)); //this Integer.parseInt conversion is printing numberformatexception
output:
eventDateStart: .20200329.
java.lang.NumberFormatException: For input string: "20200329"