Program: 10994
Project: 10994
Buggy source:
@Override public Object visitDateTimeLiteral(@NotNull cqlParser.DateTimeLiteralContext ctx){
  String input=ctx.getText();
  if (input.startsWith("String_Node_Str")) {
    input=input.substring(1);
  }
  Pattern dateTimePattern=Pattern.compile("String_Node_Str");
  Matcher matcher=dateTimePattern.matcher(input);
  if (matcher.matches()) {
    try {
      GregorianCalendar calendar=(GregorianCalendar)GregorianCalendar.getInstance();
      DateTime result=of.createDateTime();
      int year=Integer.parseInt(matcher.group(1));
      int month=-1;
      int day=-1;
      int hour=-1;
      int minute=-1;
      int second=-1;
      int millisecond=-1;
      result.setYear(libraryBuilder.createLiteral(year));
      if (matcher.group(3) != null) {
        month=Integer.parseInt(matcher.group(3));
        if (month < 0 || month > 12) {
          throw new IllegalArgumentException(String.format("String_Node_Str",input));
        }
        result.setMonth(libraryBuilder.createLiteral(month));
      }
      if (matcher.group(5) != null) {
        day=Integer.parseInt(matcher.group(5));
        int maxDay=31;
switch (month) {
case 2:
          maxDay=calendar.isLeapYear(year) ? 29 : 28;
        break;
case 4:
case 6:
case 9:
case 11:
      maxDay=30;
    break;
default :
  break;
}
if (day < 0 || day > maxDay) {
throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
result.setDay(libraryBuilder.createLiteral(day));
}
if (matcher.group(10) != null) {
hour=Integer.parseInt(matcher.group(10));
if (hour < 0 || hour > 24) {
throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
result.setHour(libraryBuilder.createLiteral(hour));
}
if (matcher.group(12) != null) {
minute=Integer.parseInt(matcher.group(12));
if (minute < 0 || minute >= 60 || (hour == 24 && minute > 0)) {
throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
result.setMinute(libraryBuilder.createLiteral(minute));
}
if (matcher.group(14) != null) {
second=Integer.parseInt(matcher.group(14));
if (second < 0 || second >= 60 || (hour == 24 && second > 0)) {
throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
result.setSecond(libraryBuilder.createLiteral(second));
}
if (matcher.group(16) != null) {
millisecond=Integer.parseInt(matcher.group(16));
if (millisecond < 0 || (hour == 24 && millisecond > 0)) {
throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
result.setMillisecond(libraryBuilder.createLiteral(millisecond));
}
if ((matcher.group(7) != null && matcher.group(7).equals("String_Node_Str")) || ((matcher.group(18) != null) && matcher.group(18).equals("String_Node_Str"))) {
result.setTimezoneOffset(libraryBuilder.createLiteral(0.0));
}
if (matcher.group(20) != null) {
int offsetPolarity=matcher.group(20).equals("String_Node_Str") ? 1 : 0;
if (matcher.group(23) != null) {
int hourOffset=Integer.parseInt(matcher.group(21));
if (hourOffset < 0 || hourOffset > 14) {
  throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
int minuteOffset=Integer.parseInt(matcher.group(23));
if (minuteOffset < 0 || minuteOffset >= 60 || (hourOffset == 14 && minuteOffset > 0)) {
  throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
result.setTimezoneOffset(libraryBuilder.createLiteral((double)(hourOffset + (minuteOffset / 60)) * offsetPolarity));
}
 else {
if (matcher.group(21) != null) {
  int hourOffset=Integer.parseInt(matcher.group(21));
  if (hourOffset < 0 || hourOffset > 14) {
    throw new IllegalArgumentException(String.format("String_Node_Str",input));
  }
  result.setTimezoneOffset(libraryBuilder.createLiteral((double)(hourOffset * offsetPolarity)));
}
}
}
result.setResultType(libraryBuilder.resolveTypeName("String_Node_Str","String_Node_Str"));
return result;
}
 catch (RuntimeException e) {
throw new IllegalArgumentException(String.format("String_Node_Str",input),e);
}
}
 else {
throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
}

Fixed version (ground truth):
@Override public Object visitDateTimeLiteral(@NotNull cqlParser.DateTimeLiteralContext ctx){
  String input=ctx.getText();
  if (input.startsWith("String_Node_Str")) {
    input=input.substring(1);
  }
  Pattern dateTimePattern=Pattern.compile("String_Node_Str");
  Matcher matcher=dateTimePattern.matcher(input);
  if (matcher.matches()) {
    try {
      GregorianCalendar calendar=(GregorianCalendar)GregorianCalendar.getInstance();
      DateTime result=of.createDateTime();
      int year=Integer.parseInt(matcher.group(1));
      int month=-1;
      int day=-1;
      int hour=-1;
      int minute=-1;
      int second=-1;
      int millisecond=-1;
      result.setYear(libraryBuilder.createLiteral(year));
      if (matcher.group(3) != null) {
        month=Integer.parseInt(matcher.group(3));
        if (month < 0 || month > 12) {
          throw new IllegalArgumentException(String.format("String_Node_Str",input));
        }
        result.setMonth(libraryBuilder.createLiteral(month));
      }
      if (matcher.group(5) != null) {
        day=Integer.parseInt(matcher.group(5));
        int maxDay=31;
switch (month) {
case 2:
          maxDay=calendar.isLeapYear(year) ? 29 : 28;
        break;
case 4:
case 6:
case 9:
case 11:
      maxDay=30;
    break;
default :
  break;
}
if (day < 0 || day > maxDay) {
throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
result.setDay(libraryBuilder.createLiteral(day));
}
if (matcher.group(10) != null) {
hour=Integer.parseInt(matcher.group(10));
if (hour < 0 || hour > 24) {
throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
result.setHour(libraryBuilder.createLiteral(hour));
}
if (matcher.group(12) != null) {
minute=Integer.parseInt(matcher.group(12));
if (minute < 0 || minute >= 60 || (hour == 24 && minute > 0)) {
throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
result.setMinute(libraryBuilder.createLiteral(minute));
}
if (matcher.group(14) != null) {
second=Integer.parseInt(matcher.group(14));
if (second < 0 || second >= 60 || (hour == 24 && second > 0)) {
throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
result.setSecond(libraryBuilder.createLiteral(second));
}
if (matcher.group(16) != null) {
millisecond=Integer.parseInt(matcher.group(16));
if (millisecond < 0 || (hour == 24 && millisecond > 0)) {
throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
result.setMillisecond(libraryBuilder.createLiteral(millisecond));
}
if ((matcher.group(7) != null && matcher.group(7).equals("String_Node_Str")) || ((matcher.group(18) != null) && matcher.group(18).equals("String_Node_Str"))) {
result.setTimezoneOffset(libraryBuilder.createLiteral(0.0));
}
if (matcher.group(20) != null) {
int offsetPolarity=matcher.group(20).equals("String_Node_Str") ? 1 : -1;
if (matcher.group(23) != null) {
int hourOffset=Integer.parseInt(matcher.group(21));
if (hourOffset < 0 || hourOffset > 14) {
  throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
int minuteOffset=Integer.parseInt(matcher.group(23));
if (minuteOffset < 0 || minuteOffset >= 60 || (hourOffset == 14 && minuteOffset > 0)) {
  throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
result.setTimezoneOffset(libraryBuilder.createLiteral((double)(hourOffset + (minuteOffset / 60)) * offsetPolarity));
}
 else {
if (matcher.group(21) != null) {
  int hourOffset=Integer.parseInt(matcher.group(21));
  if (hourOffset < 0 || hourOffset > 14) {
    throw new IllegalArgumentException(String.format("String_Node_Str",input));
  }
  result.setTimezoneOffset(libraryBuilder.createLiteral((double)(hourOffset * offsetPolarity)));
}
}
}
result.setResultType(libraryBuilder.resolveTypeName("String_Node_Str","String_Node_Str"));
return result;
}
 catch (RuntimeException e) {
throw new IllegalArgumentException(String.format("String_Node_Str",input),e);
}
}
 else {
throw new IllegalArgumentException(String.format("String_Node_Str",input));
}
}