If you want to get the date and time in a specific pattern you can use the following:
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()); String currentDateandTime = sdf.format(new Date()); Or,
Date:
String currentDate = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()).format(new Date()); Time:
String currentTime = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()).format(new Date());