Java Time Now getNow()

Here you can find the source of getNow()

Description

Get the current timestamp

License

Open Source License

Return

A formatted representation of the current time

Declaration

public static String getNow() 

Method Source Code

//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());
    }
}

Related

  1. getNow()
  2. getNow()
  3. getNow()
  4. getNow()
  5. getNow()
  6. getNow()
  7. getNow()
  8. getNow()
  9. getNow()