默认时间是凤凰城的UTC,我想将其设置为GMT + 8(中国时区)
在hbase-site.xml中,我添加了
<t t-esc="', '.join(['%s: %s' % (attribute_value.attribute_id.name, attribute_value.name) for attribute_value in l.product_id.attribute_value_ids])"/>:
我的火花测试代码
<property>
<name>phoenix.query.dateFormatTimeZone</name>
<value>GMT+08:00</value>
<!-- <value>GMT+8</value> -->
<!-- <value>UTC+8</value> -->
<!-- <value>UTC+08:00</value> -->
<!-- <value>Asia/Shanghai</value> -->
</property>
在Phoenix中,dateStr值为def dataFrameTest(spark: SparkSession): Unit = {
import spark.implicits._
val date = new Date
val dateStr = MyDateUtil.dateFormat(date)
val curretTime = new Timestamp(date.getTime)
val re = SteamingRecord(dateStr, curretTime)
logger.info(re.toString)
val conf = HBaseConfiguration.create()
conf.set("hbase.zookeeper.property.clientPort", "2181");
conf.set("hbase.zookeeper.quorum", zookeeperQuorum)
conf.set("mapreduce.output.fileoutputformat.outputdir", outputdir);
val t = spark.createDataset(Seq(re))
t.toDF().saveToPhoenix("STEAMING_RECORD",conf,Option(CommonUtil.getZkurl))
}
,但curretTime值为2018-10-17 01:13:23
。
我希望curretTime值为2018-10-16 17:13:23.097
,这是在中国的正确时间。
STEAMING_RECORD ddl:
2018-10-17 01:13:23.xxx
我可以使用
CREATE TABLE steaming_record (
//...
dateStr varchar(32),
curretTime date
)
获取日期,但我不想在代码中使用sql
如何在Phoenix中将默认时区设置为GMT + 8?