Java tutorial
//package com.java2s; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static long[] getEntryExit(Double id, Calendar date, Connection con, PreparedStatement stmt) throws Exception { stmt.setDate(1, new java.sql.Date(date.getTimeInMillis())); // stmt.setDate(2, new java.sql.Date(date.getTimeInMillis()+1000000)); stmt.execute(); ResultSet rs = stmt.getResultSet(); if (rs != null) { if (rs.next()) { Timestamp d1 = rs.getTimestamp(1); Timestamp d2 = rs.getTimestamp(2); if (d1 != null && d2 != null) { System.out.println(id + ":" + new SimpleDateFormat("dd/MM/yyyy").format(date.getTime()) + ":" + d1.toString()); long[] res = new long[] { d1.getTime(), d2.getTime() }; return res; } } rs.close(); } return null; } }