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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.tanpu.fund.utils;
import java.util.List;
import java.util.Set;
public class SqlUtils {
/**
* List<String> 转字符串 逗号分割且元素加引号
*
* @param list
* @return
*/
public static String toInStr(List<String> list) {
StringBuffer str = new StringBuffer();
for (int i=0; i< list.size(); i++) {
if(i==0) {
str.append("'").append(list.get(i)).append("'");
} else {
str.append(",").append("'").append(list.get(i)).append("'");
}
}
return str.toString();
}
/**
* List<Integer> 转字符串 逗号分割且元素加引号
*
* @param list
* @return
*/
public static String toStr(List<Integer> list) {
StringBuffer str = new StringBuffer();
for (int i=0; i< list.size(); i++) {
if(i==0) {
str.append(list.get(i));
} else {
str.append(",").append(list.get(i));
}
}
return str.toString();
}
/**
* Set<String> 转字符串 逗号分割且元素加引号
*
* @param list
* @return
*/
public static String toInStr(Set<String> list) {
StringBuffer str = new StringBuffer();
int i=0;
for (String item:list) {
if(i==0) {
str.append("'").append(item).append("'");
} else {
str.append(",").append("'").append(item).append("'");
}
i++;
}
return str.toString();
}
}