apache-commons-dateutils

Convert Date String into Epoch in Java [duplicate]

旧巷老猫 提交于 2019-12-07 06:33:33
问题 This question already has answers here : Convert a date format in epoch (5 answers) Closed 3 years ago . Is there a way to convert a given Date String into Milliseconds ( Epoch Long format) in java? Example : I want to convert public static final String date = "04/28/2016"; into milliseconds (epoch). 回答1: The getTime() method of the Date class returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object. 回答2: You can simply parse it to java.util.Date

Convert Date String into Epoch in Java [duplicate]

…衆ロ難τιáo~ 提交于 2019-12-05 11:06:05
This question already has an answer here: Convert a date format in epoch 5 answers Is there a way to convert a given Date String into Milliseconds ( Epoch Long format) in java? Example : I want to convert public static final String date = "04/28/2016"; into milliseconds (epoch). The getTime() method of the Date class returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object. You can simply parse it to java.util.Date using java.text.SimpleDateFormat and call it's getTime() function. It will return the number of milliseconds since Jan 01 1970. public