Skip to content

Instantly share code, notes, and snippets.

@tushroy
Last active January 1, 2016 12:49
Show Gist options
  • Save tushroy/8147154 to your computer and use it in GitHub Desktop.
Save tushroy/8147154 to your computer and use it in GitHub Desktop.
int day = datePicker.getDayOfMonth();
int month = datePicker.getMonth() + 1; //plus 1 for making correct format
int year = datePicker.getYear();
long unixtime;
String date = ""+day+month+year; //making String for SimpleDateFormat
DateFormat dfm = new SimpleDateFormat("ddMMyyyy"); // instantiate SimpleDateFormat
try{
unixtime = dfm.parse(date).getTime(); //getting timestamp in milis
unixtime=unixtime/1000L; // getting timestamp in unix time
}
catch (ParseException e){
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment