Java Date Now getCurrentTime(String format)

Here you can find the source of getCurrentTime(String format)

Description

get Current Time

License

Open Source License

Declaration

public static String getCurrentTime(String format) 

Method Source Code

//package com.java2s;
/*//  w  w w  .j ava  2  s .  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.Date;

public class Main {
    public static String getCurrentTime() {
        return timeToString(System.currentTimeMillis());
    }

    public static String getCurrentTime(String format) {
        return timeToString(System.currentTimeMillis(), format);
    }

    public static String timeToString(long time) {
        return timeToString(time, "yyyy-MM-dd HH:mm:ss");
    }

    public static String timeToString(long time, String format) {
        SimpleDateFormat dayTime = new SimpleDateFormat(format);
        return dayTime.format(new Date(time));
    }
}

Related

  1. getCurrentTime(Date _d)
  2. getCurrentTime(long delay, long interval)
  3. getCurrentTime(String format)
  4. getCurrentTime(String format)
  5. getCurrentTime(String format)
  6. getCurrentTime(String format)
  7. getCurrentTime(String formatter)
  8. getCurrentTime(String pattern)
  9. getCurrentTime(String pattern)