Java tutorial
//package com.java2s; /* * Zirco Browser for Android * * Copyright (C) 2010 - 2011 J. Devauchelle and contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 3 as published by the Free Software Foundation. * * 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. */ import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { /** * Get a string representation of the current date / time in a format suitable for a file name. * @return A string representation of the current date / time. */ public static String getNowForFileName() { Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmmss"); return sdf.format(c.getTime()); } }