I have a String date = dd/MM/yyyy
. How can I parse it to long? Have I to get the day, parse to long, get the month, parse to long, get the year, parse to long and then concatenate?
Thanks,
I have a String date = dd/MM/yyyy
. How can I parse it to long? Have I to get the day, parse to long, get the month, parse to long, get the year, parse to long and then concatenate?
Thanks,
Use the Formatter to parse the date:
DateFormat df = new SimpleDateFormat("dd/MM/yyy");
Long date = df.parse("12/12/2014").getTime();
using simpledateformat you can easily achieve this
public class test {
public static void main(String[] args) {
String currentDate = "01-March-2016";
SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yyyy");
Date parseDate = f.parse(currentDate);
long milliseconds = parseDate.getTime();
}
}
for More information click Here