Java Date Convert DateToMask(Date javaDateType)

Here you can find the source of DateToMask(Date javaDateType)

Description

Date To Mask

License

Apache License

Declaration

public static String DateToMask(Date javaDateType) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static String DateToMask(Date javaDateType) {
        Calendar dt = Calendar.getInstance();
        dt.setTime(javaDateType);//from w w  w . java2s . c  om

        String dia = String.valueOf(dt.get(Calendar.DAY_OF_MONTH));
        String mes = String.valueOf(dt.get(Calendar.MONTH) + 1);
        String ano = String.valueOf(dt.get(Calendar.YEAR));

        while (dia.length() < 2) {
            dia = "0".concat(dia);
        }
        while (mes.length() < 2) {
            mes = "0".concat(mes);
        }
        while (ano.length() < 4) {
            ano = "0".concat(ano);
        }

        return dia.concat("/").concat(mes).concat("/").concat(ano);
    }
}

Related

  1. dateToFMDate(Date date)
  2. dateToInt(Date date)
  3. dateToISOXDSb(Date date)
  4. dateToJulian(Date date)
  5. dateToLong(final Date date)
  6. dateToMorining(Date date)
  7. dateToNumber(Date date)
  8. dateToQTime(final Date date)
  9. dateToRRNDate(Date date)