Android Time Get getCurrentTimeString()

Here you can find the source of getCurrentTimeString()

Description

get Current Time String

Declaration

public static String getCurrentTimeString() 

Method Source Code

//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static String getCurrentTimeString() {
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        String second = cal.get(Calendar.SECOND) < 10 ? "0"
                + cal.get(Calendar.SECOND) : "" + cal.get(Calendar.SECOND);
        String minute = cal.get(Calendar.MINUTE) < 10 ? "0"
                + cal.get(Calendar.MINUTE) : "" + cal.get(Calendar.MINUTE);
        String hour = cal.get(Calendar.HOUR_OF_DAY) < 10 ? "0"
                + cal.get(Calendar.HOUR_OF_DAY) : ""
                + cal.get(Calendar.HOUR_OF_DAY);

        String strDate = cal.get(Calendar.YEAR)
                + (cal.get(Calendar.MONTH) + 1)
                + cal.get(Calendar.DAY_OF_MONTH) + hour + minute + second;
        return strDate;
    }//from w ww.j a v  a 2  s . co  m
}

Related

  1. Now(String time)
  2. toTime(int time)
  3. getCurrentTime()
  4. intConvertTime(int hour, int minut)
  5. getCurrentTime(String format)
  6. getCurrentDateTime()
  7. getCurrentTime()
  8. getFormatShortTime(Date date)
  9. getFormatTime(Date date)