public static long getCurrentEpochTimeStamp(String timeStamp) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy-MM-dd\'T\'HH:mm:ss\'.0Z\'\");
Set time zone to your SimpleDateFormat
object.
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
Date is always in UTC and you cannot convert it. The problem is how to parse string representation. If timeStamp contains timezone, then pattern "yyyy-MM-dd'T'HH:mm:ss'.0Z'" is incorrect because it does not parse timezone. It should be "yyyy-MM-dd'T'HH:mm:ssZ" if timezone is in RFC 822 format, use X
instead of Z
if timezone is in ISO 8601. See SimpleDateFormat API