2

I am trying to convert a string (UTC time) to timestamp.

List<String> list = new ArrayList<String>();
    list.add("2018-03-11 02:00:00");
    list.add("2018-03-11 03:00:00");
sparkSession.createDataset(list, Encoders.STRING()).select(to_timestamp(col("value").cast(DataTypes.TimestampType), "yyyy-MM-dd HH:mm:ss")).show();

The output for this is

+-------------------+
|              value|
+-------------------+
|2018-03-11 03:00:00|
|2018-03-11 03:00:00|
+-------------------+

I can see that its applying the DST (CST), which should not be applied in my case as I am dealing with UTC string.

Any ideas?

goutham
  • 31
  • 7

1 Answers1

0

You are using date time string without timezone component. When you convert string to timestamp and displaying. I guess it is showing in local timezone.

Ramdev Sharma
  • 974
  • 1
  • 12
  • 17