Here you can find the source of readDate(ResultSet result, int index)
Parameter | Description |
---|---|
results | The result set. |
index | The index. |
Parameter | Description |
---|---|
SQLException | an exception |
public static Date readDate(ResultSet result, int index) throws SQLException
//package com.java2s; /********************************************************************************** * $URL$//from ww w. ja v a2 s . c om * $Id$ *********************************************************************************** * * Copyright (c) 2007, 2008 The Regents of the University of Michigan & Foothill College, ETUDES Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * **********************************************************************************/ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Date; public class Main { /** * Read a long from the result set, and convert to a null (if 0) or a Date. * * @param results * The result set. * @param index * The index. * @return The Date or null. * @throws SQLException */ public static Date readDate(ResultSet result, int index) throws SQLException { long time = result.getLong(index); if (time == 0) return null; return new Date(time); } }