Java Year From yearFromFileName(String str)

Here you can find the source of yearFromFileName(String str)

Description

Filename Eg : en.13.3.1.2009.6.11

License

Open Source License

Parameter

Parameter Description
str filename

Return

year from filename

Declaration

public static int yearFromFileName(String str) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from   ww  w. j av a 2s  . co m
     * Filename Eg : en.13.3.1.2009.6.11
     * @param str filename
     * @return year from filename
     */
    public static int yearFromFileName(String str) {
        try {
            return Integer.parseInt(str.split("\\.")[4]);
        } catch (ArrayIndexOutOfBoundsException e) {
            return -1;
        }
    }
}

Related

  1. year(Date date)
  2. year(long time)
  3. yearformMatDate(Date date)
  4. yearFromDate(String date)
  5. yearFromDateValue(long x)
  6. yearOfDate(Date s)
  7. yearsBetween(String from, String to)