简体   繁体   English

如何将时间字符串转换为自定义日期格式?

[英]How to convert time string to custom Date format?

I have a column in my spark dataframe called "Fiscal Month" in which the values are "January 2015","February 2015" and so on. 我在spark数据框中有一个名为“ Fiscal Month”的列,其值是“ 2015年1月”,“ 2015年2月”,依此类推。 So the format is "Month Year" which has the datatype String. 因此,格式为“月份年”,其数据类型为字符串。

How do I convert this to a date format using Spark SQL? 如何使用Spark SQL将其转换为日期格式?

using unix_timestamp something like 使用unix_timestamp类似

import org.apache.spark.sql.functions.unix_timestamp

df.select(unix_timestamp($"Fiscal Month","MMMM yy"))

See functions object. 参见函数对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM