Here you can find the source of getNow()
public static String getNow()
//package com.java2s; /**************************************************************************** * Tuning and Analysis Utilities * http://www.cs.uoregon.edu/research/paracomp/tau **************************************************************************** * Copyright (c) 1997-2006/* www .ja v a2 s . c om*/ * Department of Computer and Information Science, University of Oregon * Advanced Computing Laboratory, Los Alamos National Laboratory * Research Center Juelich, ZAM Germany * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Wyatt Spear - initial API and implementation ****************************************************************************/ import java.util.Calendar; import java.util.TimeZone; public class Main { /** * Get the current timestamp * * @return A formatted representation of the current time */ public static String getNow() { final Calendar cal = Calendar.getInstance(TimeZone.getDefault()); final String DATE_FORMAT = "yyyy-MM-dd_HH-mm-ss"; //$NON-NLS-1$ final java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT); sdf.setTimeZone(TimeZone.getDefault()); return sdf.format(cal.getTime()); } }