0

I'm trying to union two Dstreams:

val statuses = tweets.map(status => status.getText())
    val users = tweets.map(status => status.getUser())
    val Dates = tweets.map(status => status.getCreatedAt())
    (statuses. union(Dates)).print

But I'm getting an error that there is a mismatch in types:

Found: org.apache.spark.streaming.dstream.DStream[java.util.Date]

Required: org.apache.spark.streaming.dstream.DStream[String]

How can I do the conversion?

Lisa
  • 3,121
  • 15
  • 53
  • 85
  • possible duplicate of [Convert java.util.Date to String](http://stackoverflow.com/questions/5683728/convert-java-util-date-to-string) – Justin Pihony Apr 03 '15 at 04:01

1 Answers1

2

try this

val Dates = tweets.map(status => status.getCreatedAt.toString)

or if you want specific format

val format = new SimpleDateFormat("yyyy-MM-dd")
val Dates = tweets.map(status => format.format(status.getCreatedAt))
Marek Adamek
  • 500
  • 3
  • 7