Java Time Now getTimeString()

Here you can find the source of getTimeString()

Description

Helper method that returns the date and time in a format that can be used to create filenames.

License

Open Source License

Return

the formatted time string

Declaration

public static String getTimeString() 

Method Source Code

//package com.java2s;
/*//from   w  ww.j  av  a2  s . c om
 * Part of Simbrain--a java-based neural network kit
 * Copyright (C) 2005,2007 The Authors.  See http://www.simbrain.net/credits
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

import java.text.SimpleDateFormat;

import java.util.Calendar;

public class Main {
    /**
     * Helper method that returns the date and time in a format that can be used
     * to create filenames.
     * 
     * @return the formatted time string
     */
    public static String getTimeString() {
        return new SimpleDateFormat("MM-dd-YY_k-mm").format(Calendar.getInstance().getTime());
    }
}

Related

  1. getNowYMD()
  2. getSpecifiedDateTime_235959(Date curDate)
  3. getStrCurrentStrTime()
  4. getThaiCurrentTime()
  5. getTimeFromCurrent(long l)
  6. getTimeString()
  7. getTimeString()
  8. getTimeString()
  9. printTime()