Format Calendar in yyyy-MM-dd-hh-mm-ss format - Android java.util

Android examples for java.util:Calendar Format

Description

Format Calendar in yyyy-MM-dd-hh-mm-ss format

Demo Code


//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    public static String date() {
        SimpleDateFormat format = new SimpleDateFormat(
                "yyyy-MM-dd-hh-mm-ss");
        Calendar c = Calendar.getInstance();
        String date = format.format(c.getTime());
        return date;
    }/*from  w  w w .j  av a  2  s  .  c o  m*/
}

Related Tutorials