Java Date Now getCurrentTimeStr()

Here you can find the source of getCurrentTimeStr()

Description

get Current Time Str

License

Open Source License

Declaration

public static String getCurrentTimeStr() 

Method Source Code

//package com.java2s;
/**/*from  www  .  ja v a2 s.  c o  m*/
 * Copyright @ 2007, ST Electronics Info-comm Systems PTE. LTD All rights
 * reserved.
 *
 * This software is confidential and proprietary property of ST Electronics
 * Info-comm Systems PTE. LTD. The user shall not disclose the contents of this
 * software and shall only use it in accordance with the terms and conditions
 * stated in the contract or licence agreement with ST Electronics Info-comm
 * Systems PTE. LTD.
 *
 * @author Jerry
 * @version 1.0
 *
 */

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static String getCurrentTimeStr() {
        Date date = new Date(System.currentTimeMillis());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-SSS");
        String dateStr = sdf.format(date);
        String[] dateArray = dateStr.split("-");
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < dateArray.length; i++) {
            sb.append(dateArray[i]);
        }
        return sb.toString();
    }
}

Related

  1. getCurrentTimestamp()
  2. getCurrentTimeStamp()
  3. getCurrentTimestamp()
  4. getCurrentTimestampAsISOString()
  5. getCurrentTimestampString()
  6. getCurrentTimeStr()
  7. getCurrentTimeString(String format)
  8. getCurrentTimeString(String pattern)
  9. getCurrentToNextDaySecond()