I have a date inside a string, something like "12-December-2012". How can I convert this into milliseconds (long)?
This is the number of seconds since the 1970 epoch. To convert seconds to milliseconds, you need to multiply the number of seconds by 1000. To convert a Date to milliseconds, you could just call timeIntervalSince1970 and multiply it by 1000 every time.
In Kotlin, Wed Oct 12 11:55:03 GMT+05:30 2011 long millisecond = beginupd. getTime(); Date.
The DateTime. ToLongDateString() method in C# is used to convert the value of the current DateTime object to its equivalent long date string representation.
Using SimpleDateFormat
String string_date = "12-December-2012"; SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yyyy"); try { Date d = f.parse(string_date); long milliseconds = d.getTime(); } catch (ParseException e) { e.printStackTrace(); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With