Java examples for JDBC:ResultSet
Transforms a given column from the java.sql.ResultSet from a java.sql.Timestamp to a java.util.Calendar.
/*//from w w w .j a v a 2s.com * Adito * * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ //package com.java2s; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; import java.util.Calendar; public class Main { /** * Transforms a given column from the java.sql.ResultSet from a * java.sql.Timestamp to a java.util.Calendar. * * @param resultSet * @param columnName * @return java.util.Calendar * @throws SQLException */ public static Calendar getCalendar(ResultSet resultSet, String columnName) throws SQLException { return getCalendar(resultSet.getTimestamp(columnName)); } /** * Transforms the supplied java.sql.Timestamp into a java.util.Calendar. * * @param timestamp * @return java.util.Calendar */ public static Calendar getCalendar(Timestamp timestamp) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timestamp == null ? System .currentTimeMillis() : timestamp.getTime()); return calendar; } }