spark time 转 string

spark time 转 string,第1张

spark time 转 string
import org.apache.spark.SparkConf
import org.apache.spark.streaming.{Seconds, StreamingContext}

import java.time.Instant



val conf = new SparkConf().setMaster("local[2]").setAppName("NetworkWordCount")
val ssc = new StreamingContext(conf, Seconds(1))       

 val lines = ssc.socketTextStream("localhost", 9999)
        val windowedWordCounts = lines.window(Seconds(4), Seconds(2))
        windowedWordCounts.foreachRDD(
            (rdd, time) => {
                println(Instant.ofEpochMilli(time.milliseconds))
                rdd
            }
        )

ssc.start()
ssc.awaitTermination()

// spark打印时间 spark时间 bigint 2 string

打印结果:
2021-11-08T01:10:14Z 

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5154131.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-18
下一篇 2022-11-18

发表评论

登录后才能评论

评论列表(0条)

保存