Android examples for java.util:Date Format
get Date Time as format yyyyMMdd-hhmmss
/******************************************************************************* * Copyright (c) 2014 Hoang Nguyen./*from w w w . j a va2 s. c om*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v2.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Contributors: * Hoang Nguyen - initial API and implementation ******************************************************************************/ //package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { final static String getDateTime() { SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd-hhmmss"); return df.format(Calendar.getInstance().getTime()); } }