Java Date Now getCurrentSecond()

Here you can find the source of getCurrentSecond()

Description

get Current Second

License

Open Source License

Declaration

public static String getCurrentSecond() 

Method Source Code

//package com.java2s;
/*/*  w ww . j  a v a 2s.c  o m*/
 * M2M ServiceFOTA ONM version 1.0
 *
 *  Copyright ? 2014 kt corp. All rights reserved.
 *
 *  This is a proprietary software of kt corp, and you may not use this file except in
 *  compliance with license agreement with kt corp. Any redistribution or use of this
 *  software, with or without modification shall be strictly prohibited without prior written
 *  approval of kt corp, and the copyright notice above does not evidence any actual or
 *  intended publication of such software.
 */

import java.text.SimpleDateFormat;
import java.util.Calendar;

import java.util.Locale;

public class Main {

    public static String getCurrentSecond() {

        return getCurrentFormat("ss");
    }

    public static String getCurrentFormat(String format) {

        Calendar cal = Calendar.getInstance(Locale.KOREA);

        SimpleDateFormat df = null;

        try {
            df = new SimpleDateFormat(format);
            return df.format(cal.getTime());
        } catch (Exception e) {
            return "";
        } finally {
            cal = null;
            df = null;
        }
    }
}

Related

  1. getCurrentMonthStartTime()
  2. getCurrentMonthString(Calendar calendar)
  3. getCurrentODSDate()
  4. getCurrentPlainDate()
  5. getCurrentQuarter()
  6. getCurrentString(String pattern)
  7. getCurrentStringDate()
  8. getCurrentStringDate(String pattern)
  9. getCurrentStringDateYMD()