Here you can find the source of getString(ResultSet rs, int ix, int sql_type)
public static String getString(ResultSet rs, int ix, int sql_type) throws SQLException
//package com.java2s; /*//from w w w .j a v a 2 s. c o m * #! * Ontopia DB2TM * #- * Copyright (C) 2001 - 2013 The Ontopia 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.Date; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; import java.sql.Types; import java.text.DateFormat; import java.text.SimpleDateFormat; public class Main { static DateFormat df_date = new SimpleDateFormat("yyyy-MM-dd"); static DateFormat df_datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static String getString(ResultSet rs, int ix, int sql_type) throws SQLException { switch (sql_type) { case Types.DATE: Date date = rs.getDate(ix); if (date == null) return null; return df_date.format(date); case Types.TIMESTAMP: Timestamp timestamp = rs.getTimestamp(ix); if (timestamp == null) return null; return df_datetime.format(timestamp); default: return rs.getString(ix); } } }