-1
  def run : List[Map[String,Any]]={

    val startTime = "19-9-2014 23:00"
    val endTime = "19-9-2014 13:15"
    val df: SimpleDateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm")
    val calendar: Calendar = Calendar.getInstance
    val finalTime : Date = df.parse(endTime)
    var firstTime=startTime
    var timeValuePair = List[Map[String , Any]]()
    var last = new Date()
    do {

      val first: Date = df.parse(firstTime)
      calendar.setTime(first)
      calendar.add(Calendar.MINUTE, 5)
      last = calendar.getTime
      val (repAlert, slowQueryAlert, statusAlert) = AggregateAlert.test(first.toString, last.toString)
      timeValuePair=Map("repAlert"->repAlert.toString,"slowQueryAlert"->slowQueryAlert.toString,"statusAlert"->statusAlert.toString) :: timeValuePair
      firstTime=last.toString
    }while(last.compareTo(finalTime)<0)

I basically need to send date and time in the format of dd-mmm-yyyy hh:mm to the function AggregateAlert for every 5 minutes interval between the startTime and endTime. However with my code I am getting "first" as "Fri Sep 19 11:00:00 IST 2014" and "last" as "Fri Sep 19 19:01:21 IST 2014". However I want the same format as dd-mmm-yyyy. Is there anyway to convert this to the required format?

Thanks in advance!

Tanvi
  • 413
  • 1
  • 5
  • 14

1 Answers1

0

Try :

      val (repAlert, slowQueryAlert, statusAlert) = 
AggregateAlert.test(df.format(first), df.format(last))
Tanvi
  • 413
  • 1
  • 5
  • 14