Q:

Convert from Gregorian to Julian calendar

I  need to create a program that reads dates from a .csv file and convert it so that 13 days are added. I already did that but somehow it does not add the following dates as wished. It also goes over 30 days, which is not supposed to happen for example 2001-12-42.
public static void main(String[] args) throws FileNotFoundException, ParseException {
    File fread = new File("src/daten-greg.csv");
    File fwrite = new File("src/daten-jul.csv");

    Scanner s = new Scanner(fread);
    PrintStream print = new PrintStream(fwrite);

    while(s.hasNext()) {
        String[] line = s.nextLine().split(" ");
        print.println(String.join(" ", Convert(line)));
    }

    s.close();
    print.close();
}

private static String[] Convert(String[] value) throws ParseException {
    for (int i = 0; i < value.length; i+=1)
        value[i] = ToJulianisch(value[i]);

    return value;
}

private static String ToJulianisch(String date) throws ParseException {
    SimpleDateFormat  sdf = new SimpleDateFormat("yyyy-mm-dd");
    Date d = sdf.parse(date);

    Calendar c = Calendar.getInstance();
    c.setTime(d);

    int actDay = c.get(Calendar.DAY_OF_MONTH);
    int actMonth = c.get(Calendar.MONTH) + 1 ;
    int actYear = c.get(Calendar.YEAR);
    actDay -= 13;

    if(actDay - 13 < 1) {
        actMonth -= 1;
        if(actMonth < 1) {
            actMonth = 12;
            actYear -= 1;
        }   
        Calendar k = Calendar.getInstance();
        k.set(Calendar.YEAR, actYear);
        k.set(Calendar.MONTH, actMonth - 1);
        actDay = k.getActualMaximum(Calendar.DAY_OF_MONTH) + actDay;
    }

    return String.format("%s-%s-%s", actYear, actMonth, actDay);
}

A:

You are subtracting 13 from actDay twice, first in actDay-=13 and again for  if(actDay - 13 < 1). Inside the if block, you then add the value which is less than 14 to the number of days per month, resulting in overflowing the day of month.
If you simply want to subtract 13 days from the given date, you should use c.set(Calendar.DAY_OF_MONTH,actDay-13). This will handle the subtraction correctly inside the Calendar object and you can then use
actDay = c.get(Calendar.DAY_OF_MONTH);
int actMonth = c.get(Calendar.MONTH) + 1 ;
int actYear = c.get(Calendar.YEAR);
return String.format("%s-%s-%s", actYear, actMonth, actDay);

