Java Date to Timestamp timestamp(Calendar date)

Here you can find the source of timestamp(Calendar date)

Description

timestamp

License

Open Source License

Declaration

public static String timestamp(Calendar date) 

Method Source Code

//package com.java2s;
//License from project: GNU General Public License 

import java.text.DecimalFormat;

import java.util.Calendar;

public class Main {
    public static String timestamp(long millis) {
        Calendar date = Calendar.getInstance();
        date.setTimeInMillis(millis);/*  w  ww  . ja v a  2 s  .c om*/
        return timestamp(date);
    }

    public static String timestamp(Calendar date) {
        DecimalFormat format = new DecimalFormat("00");
        int month = date.get(Calendar.MONTH) + 1;
        int day = date.get(Calendar.DAY_OF_MONTH);
        int hour = date.get(Calendar.HOUR_OF_DAY);
        int minute = date.get(Calendar.MINUTE);
        int second = date.get(Calendar.SECOND);
        return "" + date.get(Calendar.YEAR) + format.format(month) + format.format(day) + format.format(hour)
                + format.format(minute) + format.format(second);
    }
}

Related

  1. getTimestamp(Date date)
  2. getTimestamp(Date date)
  3. getTimestamp(Date date)
  4. getTimeStamp(Date date, String time)
  5. removeTimestamp(Date date)
  6. timestamp(Date d)
  7. timeStamp(Date date)
  8. timestamp(Date dateAndTime)
  9. timestampSec(Date date)