Java Date String to String dateToInt(String date)

Here you can find the source of dateToInt(String date)

Description

date To Int

License

Apache License

Declaration

public static int dateToInt(String date) 

Method Source Code

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

public class Main {

    public static int dateToInt(String date) {
        int intDate = 0;
        if (date.length() == 8 && date.indexOf("-") < 0) {
            intDate = Integer.valueOf(date).intValue();
        } else if (date.length() == 10 && date.indexOf("-") > 0) {
            intDate = Integer.valueOf(getYYYYMMDD(date)).intValue();
        } else if (date.length() == 6 || date.length() == 4) {
            intDate = Integer.valueOf(date).intValue();
        }/*  ww  w. j a v  a  2 s .  co  m*/
        return intDate;
    }

    public static String getYYYYMMDD(String date) {
        String YYYYMMDD = "";
        YYYYMMDD = date.substring(0, 4) + date.substring(5, 7) + date.substring(8);
        return YYYYMMDD;
    }
}

Related

  1. dateToDateEN(String in)
  2. dateToFileName(String date)
  3. dateToString(String date)
  4. dateToString(String date, String month)
  5. adjustDate(String format, String value)