Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import android.annotation.SuppressLint; public class Main { @SuppressLint("SimpleDateFormat") public static String getCTime(String pattern) { SimpleDateFormat simpleDate = new SimpleDateFormat(pattern); Calendar calendar = Calendar.getInstance(); String currentTime = simpleDate.format(calendar.getTime()); return currentTime; } }