How to resolve the algorithm Date manipulation step by step in the NetRexx programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Date manipulation step by step in the NetRexx programming language

Table of Contents

Problem Statement

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.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Date manipulation step by step in the NetRexx programming language

Source code in the netrexx programming language

/* 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

  

You may also check:How to resolve the algorithm 100 doors step by step in the HolyC programming language
You may also check:How to resolve the algorithm Bin given limits step by step in the Haskell programming language
You may also check:How to resolve the algorithm Fork step by step in the Go programming language
You may also check:How to resolve the algorithm Fusc sequence step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Count occurrences of a substring step by step in the APL programming language