Here you can find the source of getCurrentTimeStr()
public static String getCurrentTimeStr()
//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(); } }