public static void edit(
     Long id, SchoolClass schoolClass, String date, String kindOfAssignment, String description) {
   Assignment assignment = find.ref(id);
   assignment.schoolClass = schoolClass;
   String[] array = parseDate(date);
   String dueDate = array[0];
   assignment.dueDate = dueDate;
   int year = Integer.parseInt(array[1]);
   assignment.year = year;
   int month = Integer.parseInt(array[2]);
   assignment.month = month;
   int day = Integer.parseInt(array[3]);
   assignment.day = day;
   assignment.spanner = kindOfAssignment.substring(0, 1);
   assignment.description = description;
   assignment.total = (year * 366) - ((12 - month) * 31) - (31 - day);
   try {
     assignment.save();
   } catch (PersistenceException e) {
     System.err.println("Unable to save an assignment after editing. ID: " + id);
   }
 }
  public static Assignment create(
      String dueDate,
      String schoolClassId,
      String kindOfAssignment,
      String description,
      String foreignID) {
    String month = "";
    String day = "";
    String year = "";

    for (int i = 0; i < dueDate.length(); i++) {
      if (dueDate.charAt(i) == ('-')) continue;
      if (i < 4) year = year + (String.valueOf(dueDate.charAt(i)));
      if (i > 4 && i < 7) month = month + (String.valueOf(dueDate.charAt(i)));
      if (i > 7 && i < dueDate.length()) day = day + (String.valueOf(dueDate.charAt(i)));
    }

    int monthInt = Integer.parseInt(month);
    int dayInt = Integer.parseInt(day);
    int yearInt = Integer.parseInt(year);

    switch (Integer.parseInt(month)) {
      case 1:
        month = "January";
        break;
      case 2:
        month = "Feburary";
        break;
      case 3:
        month = "March";
        break;
      case 4:
        month = "April";
        break;
      case 5:
        month = "May";
        break;
      case 6:
        month = "June";
        break;
      case 7:
        month = "July";
        break;
      case 8:
        month = "August";
        break;
      case 9:
        month = "September";
        break;
      case 10:
        month = "October";
        break;
      case 11:
        month = "November";
        break;
      case 12:
        month = "December";
        break;
    }

    String date = month + " " + day + ", " + year;

    Long schoolId = null;
    try {
      schoolId = Long.valueOf(schoolClassId);
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (description.length() > 250) description = description.substring(0, 250);
    Assignment assignment =
        new Assignment(
            date,
            SchoolClass.find.ref(schoolId),
            kindOfAssignment,
            description,
            UUID.fromString(foreignID),
            monthInt,
            dayInt,
            yearInt);
    assignment.save();
    return assignment;
  }