kylin查詢出現日期對應不上的情況


情況:

查詢的是2016年1月2日的數據,但返回解析出來的數據確實是2號的,可是時間竟然變成了2016年1月1日。

 

解決:

是時區問題,修改本地時區

 

具體代碼,主要是看加紅加粗的:

public static void QueryTest() throws SQLException, InstantiationException,
			IllegalAccessException, ClassNotFoundException {
		System.setProperty("user.timezone","GMT +08");
		Driver driver = (Driver) Class.forName("org.apache.kylin.jdbc.Driver")
				.newInstance();
		Properties info = new Properties();
		info.put("user", "ADMIN");
		info.put("password", "KYLIN");
		info.put("useLegacyDatetimeCode", "false");
		Connection conn = driver.connect(
				"jdbc:kylin://192.168.22.102:7070/DataPlat", info);
	
		Statement state = conn.createStatement();
		
		ResultSet resultSet = state
				.executeQuery("select  cppadate,count(1) from KPI_BASE_DATACPPAFOLLOWCRCCOUNT  where  cppadate>='2016-01-12' and cppadate<='2016-01-12' group by cppadate");

		while (resultSet.next()) {
			System.out.println(resultSet.getDate(1) + "__"
					+ resultSet.getInt(2) );
		}
	}

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM