Conversion of a date to epoch Java [duplicate]
问题 This question already has answers here : SimpleDateFormat producing wrong date time when parsing “YYYY-MM-dd HH:mm” (4 answers) Closed last year . I want to convert 2018-02-21 15:47:35 UTC to epoch UTC form. How do we do it? I am currently in PST. SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-DD HH:MM:SS"); df.setTimeZone(TimeZone.getTimeZone("UTC")); date = df.parse(dateString).getTime(); The code above should return the number of milliseconds since January 1, 1970, 00:00:00 GMT , but