Skip to content

Instantly share code, notes, and snippets.

@josep2
Created December 5, 2016 23:03
Show Gist options
  • Save josep2/d1e7f0cd570e86b9951c088c88e01796 to your computer and use it in GitHub Desktop.
Save josep2/d1e7f0cd570e86b9951c088c88e01796 to your computer and use it in GitHub Desktop.
import com.cloudera.sparkts._
import java.time.{LocalDateTime, ZoneId, ZonedDateTime}
val zone = ZoneId.systemDefault() // We need to get a time zone, so I'll just use whatever is on the machine processing the data.
// Ideally, you would have the time zone for each data point before hand.
val dtIndex = DateTimeIndex.uniformFromInterval(
ZonedDateTime.of(LocalDateTime.parse("2016-01-04T00:00:00"), zone), // Look over a window from The first of January to the 3rd of october
ZonedDateTime.of(LocalDateTime.parse("2016-10-03T00:00:00"), zone),
new DayFrequency(7)) // Every seven days from Monday - Sunday will be an index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment