Task

Given the date string "March 7 2009 7:30pm EST", 

output the time 12 hours later in any human-readable format.

As extra credit, display the resulting time in a time zone different from your own.




/* NetRexx */
options replace format comments java crossref symbols binary
 
import java.text.SimpleDateFormat
import java.text.ParseException
 
runSample(arg)
return
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method manipulateDate(sampleDate, dateFmt, dHours = 0) private static
  formatter = SimpleDateFormat(dateFmt)
  msHours = dHours * 60 * 60 * 1000 -- hours in milliseconds
  day = formatter.parse(sampleDate)
  day.setTime(day.getTime() + msHours)
  formatted = formatter.format(day)
  return formatted
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
  do
    sampleDate = 'March 7 2009 7:30pm EST'
    dateFmt = "MMMM d yyyy h:mma z"
    say sampleDate
    say manipulateDate(sampleDate, dateFmt, 12)
  catch ex = Exception
    ex.printStackTrace()
  end
  return
 