Java tutorial
//package com.java2s; import android.annotation.SuppressLint; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { static String _currentDateTime; @SuppressLint("SimpleDateFormat") static String setDateTime() { // add DateTime to filename Calendar cal = Calendar.getInstance(TimeZone.getDefault()); Date currentLocalTime = cal.getTime(); SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); date.setTimeZone(TimeZone.getDefault()); _currentDateTime = date.format(currentLocalTime); return _currentDateTime; } }