Android Date Format formatcurrentDate(int format)

Here you can find the source of formatcurrentDate(int format)

Description

formatcurrent Date

Declaration

public static String formatcurrentDate(int format) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    private static final String[] SIMPLE_TIME_FORMAT = { "yyyy-MM-dd",
            "yyyy-MM-dd-HH", "yyyy-MM-dd-HH-mm", "yyyy-MM-dd-HH-mm-ss" };

    public static String formatcurrentDate(int format) {
        return formatDate(new Date(), format, "");
    }/*from   w ww. j  ava 2s. c om*/

    public static String formatDate(long timeMilliSeconds, int format) {
        return formatDate(new Date(timeMilliSeconds), format, "");
    }

    public static String formatDate(long timeMilliSeconds, int format,
            String delimiter) {
        return formatDate(new Date(timeMilliSeconds), format, delimiter);
    }

    private static String formatDate(Date date, int format, String delimiter) {
        return formatDate(format, delimiter).format(date);
    }

    private static SimpleDateFormat formatDate(int format, String delimiter) {
        assert format >= 0 && format < SIMPLE_TIME_FORMAT.length;
        String formatString = SIMPLE_TIME_FORMAT[format];
        if (delimiter != null) {
            formatString = formatString.replace("-", delimiter);
        }
        return new SimpleDateFormat(formatString);
    }
}

Related

  1. getFormatTomorrow(String format)
  2. getDisplayDate(Date date, String format)
  3. getFormatedDate(Date date, String format)
  4. dateFormat(String sdate, String format)
  5. dateFormat(String sdate, String format)
  6. formatDataTime(Date date)
  7. formatDate(Date date)
  8. formatDate(Date date)
  9. formatDate(Date date)