Here you can find the source of getSecond()
public static String getSecond()
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getSecond() { Date currentTime = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateString = formatter.format(currentTime); String min;//from w ww . j a va 2s. c om min = dateString.substring(17, 19); return min; } }