Java tutorial
//package com.java2s; import android.annotation.SuppressLint; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { static String _currentDate; static String _currentTime; @SuppressLint("SimpleDateFormat") static String futureDate() { // take current date and increment Calendar cal = Calendar.getInstance(TimeZone.getDefault()); Date currentLocalTime = cal.getTime(); SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd"); date.setTimeZone(TimeZone.getDefault()); _currentDate = date.format(currentLocalTime); try { cal.setTime(date.parse(_currentDate)); } catch (ParseException e) { e.printStackTrace(); } cal.add(Calendar.DATE, 30); _currentDate = date.format(cal.getTime()); return _currentDate; } @SuppressLint("SimpleDateFormat") static String setTime() { // add DateTime to filename Calendar cal = Calendar.getInstance(TimeZone.getDefault()); Date currentLocalTime = cal.getTime(); SimpleDateFormat date = new SimpleDateFormat("HH-mm-ss"); date.setTimeZone(TimeZone.getDefault()); _currentTime = date.format(currentLocalTime); return _currentTime; } }