SSISO Community

시소당

public static int[] parseDateStamp(String s)

public  static  int[]  parseDateStamp(String  s)  {
        s  =  s.trim();
        int  i1  =  s.indexOf("/");
        int  i2  =  s.indexOf("/",  i1  +  1);
        int[]  date  =  new  int[3];
        date[0]  =  new  Integer(s.substring(0,  i1)).intValue();
        date[1]  =  new  Integer(s.substring(i1  +  1,  i2)).intValue();
        date[2]  =  new  Integer(s.substring(i2  +  1)).intValue();
        return  date;
        /*DateFormat  dateFormat  =  DateFormat.getDateInstance(DateFormat.SHORT,  currentLocale);
        Date  d  =  null;
        try  {
                d  =  dateFormat.parse(s);
        }  catch  (Exception  ex)  {
                ex.printStackTrace();
                return  new  int[3];
        }
        int[]  ret  =  {d.getDay(),  d.getMonth(),  d.getYear()};
        return  ret;*/
}

//  2008/05/09  등과  같은  날짜를  2008  ,  5,  9  의  세개의  int[]  배열로  저장
참고로  indexOf  소개

Vector의  indexOf(  )  메소드는  2가지(오버로딩)가  있습니다.
public  int  indexOf(Object  elem)
public  int  indexOf(Object  elem,  int  index)

Vector내부에  저장된    객체중에  매개변수로  넘어온  객체를  찾아서  해당  객체가  몇번째  있는지에  대한  인덱스를  반환하는  객체입니다.
이때,  동일한  객체인지를  찾기위해  equals(  )메소드(Object  부분  참조)를  사용합니다.
그리고  동일한  객체가  여러개  있는  경우,  맨  처음  존재하는  객체의  인덱스를  반환합니다.
위의  두가지  메소드  중에  아랫부분에  있는  메소드는  매개변수로  입력되는  인덱스부터  검색하는  메소드  입니다.
동일한  객체가  Vector내에  존재  하지  않으면  반환값으로  -1을  반환합니다.

1528 view

4.0 stars