sharang gupta sharang gupta - 6 months ago 27
Android Question

I want to get the date along with the time in my android application

I tried the code below, and although I have given DateFormat.LONG as a parameter , i only get the date and not the time.How do i get both the date and time?

Date date = new Date(System.currentTimeMillis());

heres my output : 20 October 2016


Try this.

DateFormat df = new SimpleDateFormat("yyyy/MM/dd kk:mm:ss");
Calendar c    = Calendar.getInstance();
Date day      = c.getTime();
String s2     = df.format(day);