티스토리 뷰

요일을 숫자로 넣었길래......
숫자를 다시 요일로 변환하는 소스

그런데...... 숫자를 , 로 여러개를 넣어서......

그걸 전부 판별해서 요일로 바꿔주는 소스


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
for(inti=0;i<resultList.size();i++){
            if(result1.get(i).getGn_day() == null || result1.get(i).getGn_day().equals("")){
                  num = "";
            }else {
                  if(result1.get(i).getGn_day().length() > 2){
                        String dayStr = "";
                        StringTokenizer tokens = new StringTokenizer( result1.get(i).getGn_day(), ", " );
                        forint x = 1; tokens.hasMoreElements(); x++ ){
                              if(x == 1){
                                    dayStr += checkDay(tokens.nextToken());
                              }else {
                                    dayStr += ","+checkDay(tokens.nextToken());
                                    }
                        }
                        result1.get(i).setGn_day(dayStr);
                  }else {
                        num = result1.get(i).getGn_day().toString();
                        result1.get(i).setGn_day(checkDay(num));
                        }
                  }
        }
 
 
 
    public String checkDay(String gnDay) {
      String day = "";
      switch (Integer.parseInt(gnDay)) {
                  case 1: day = "월";
                        break;
                  case 2: day = "화";
                        break;
                  case 3: day = "수";
                        break;
                  case 4: day = "목";
                        break;
                  case 5: day = "금";
                        break;
                  case 6: day = "토";
                        break;
                  case 7: day = "일"
                        break;
            default:
                  break;
            }
      
            return day;
      }
 
cs


반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함