From spark 1.5.x on some convenience methods were added to deal with time.
Timestamp type can be converted to its the Unix timestamp in seconds. If this resolution is good enough for you the rest is just a bunch of arithmetic operations. You can compute difference in seconds as:
import org.apache.spark.sql.Column def secondsBetween(col1: Column, col2: Column) = col2.cast("timestamp").cast("bigint") - col1.cast("timestamp").cast("bigint")
and re-sample according to your needs, for example:
def minutesBetween(col1: Column, col2: Column) = (secondsBetween(col1, col2) / 60).cast("bigint")
Obviously this doesn't handle all the subtleties of date and time processing like daylight saving time or leap second so if these are important in your domain then UDF with proper time processing library is recommended.