java.sql.Timestamps: There's gotta be an easier way I have a function that counts how many "assists" a team performs during the course of their day.  The way I've written it feels bulky and inefficient using GregorianCalendar.  

Basically, the function counts specific types of assistance then returns the information in an object.

Does anyone know of a cleaner way to do this?

public static AssistReportData getAssistReportByDate(int teamId, Date date) throws ClassNotFoundException, SQLException {
    AssistReportData ard = null;
    Connection conn = getConnection();

    String query = "SELECT assistanceProvided FROM fauassist WHERE teamId=? AND timeOut BETWEEN ? AND ?;";

    PreparedStatement ps = conn.prepareStatement(query);
    ps.setInt(1, teamId);
    GregorianCalendar gc = new GregorianCalendar();
    gc.setTime(date);
    gc.set(Calendar.HOUR, 0);
    gc.set(Calendar.MINUTE, 0);
    gc.set(Calendar.SECOND, 0);
    ps.setTimestamp(2, new java.sql.Timestamp(gc.getTime().getTime()));
    GregorianCalendar gc2 = new GregorianCalendar();
    gc2.setTime(date);
    gc.set(Calendar.HOUR, 59);
    gc.set(Calendar.MINUTE, 59);
    gc.set(Calendar.SECOND, 59);
    ps.setTimestamp(3, new java.sql.Timestamp(gc2.getTime().getTime()));

    ResultSet rs = ps.executeQuery();
    while (rs.next()) {
        ard = new AssistReportData();
        ard.setTeam(teamId);
        switch (rs.getString("assistanceProvided")) {
            case ("TEAM EFFORT"):
                ard.addTeamEffort(1);
                break;
            case ("OUTSIDE AGENCY"):
                ard.addOutsideAgency(1);
                break;
            case("SEARCH WARRANT"):
                ard.addSearchWarrant(1);
                break;
            case("TRANSPORT"):
                ard.addTransport(1);
            default:
        }
    }
    return ard;
}
Bug

gc.set(Calendar.HOUR, 59);


I suppose you mean gc.set(Calendar.HOUR, 23); here?

Potential Bug

while (rs.next()) {
    ard = new AssistReportData();
    // ...
}


I suppose this works currently because you only get a single result row, but please be aware that if you have multiple rows, you will simply be re-referencing until the last row of your ResultSet.

Getting dates

All you need is a nice method that converts Date to Timestamp:

// using shortened variable names for brevity
private static Timestamp convertAndReset(Date date, int hr, int min, int sec, int nano) {
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(date);
    calendar.set(Calendar.HOUR, hr);
    calendar.set(Calendar.MINUTE, min);
    calendar.set(Calendar.SECOND, sec);
    Timestamp result = new Timestamp(calendar.getTimeInMillis());
    result.setNanos(nano);
    return result;
}


You can them call it as such:

ps.setInt(1, teamId);
ps.setTimestamp(2, convertAndReset(date, 0, 0, 0, 0));
ps.setTimestamp(3, convertAndReset(date, 23, 59, 59, 0));


Java 8?

If you happen to be on Java 8, then congratulations: the new java.time.* classes ('Time APIs') are much better for chronological representations.

You can then consider rewriting the same method as such:

private static Timestamp convertAndReset(Date date, int hr, int min, int sec, int nano) {
    return Timestamp.valueOf(date.toInstant().atZone(ZoneId.systemDefault())
                                    .toLocalDate().atTime(hr, min, sec, nano));        
}



Convert Date to Instant via Date.toInstant().
Convert to ZonedDateTime via Instant.atZone(ZoneId).
Convert to either a LocalDate or LocalDateTime. Using the former because...
Setting the time via LocalDate.atTime() is arguably more fluent, which gives us a LocalDateTime instance with the desired time in another 'step'.
Finally, call Timestamp.valueOf(LocalDateTime) to get the Timestamp instance.