At a quick glance, your pattern seems incorrect. The case of each pattern letter is important. For example, “MM” is equivalent to “month in year” whereas “mm” is “minute in hour”. Trying setting the appropriate pattern first and see if that helps.
Also, consider passing the pattern in as an input to the service. It it will make your service more reusable. Similarly, consider an input that dictates whether the service returns the epoch in seconds or milliseconds. I see that you’re dividing by 1000 to get seconds, but there are systems that expect the epoch to be in milliseconds so it may help you in the long run to support returning milliseconds as well.