Object->Map
Map->Collection
Collection<V> values() //Map类的方法
Array->List
import org.apache.commons.collections.CollectionUtils;
CollectionUtils.addAll(strList, strArray);
CollectionUtils.addAll(strSet, strArray);
---
List<String> players = Arrays.asList(strArray); //注:此playersList不能add或remove对象,因为大小已由数据决定。
Set <-> List
List<String> result = new ArrayList<>(mySet);
Set result = new HashSet(myList);
->Array
Collection.toArray()
/*ArrayList ,EnumSet , HashSet ,LinkedHashSet , LinkedList , Stack , TreeSet , Vector */
->String
String.copyValueOf(charArray) #Array->String
Arrays.toSting() #Array->String
Date -> String
//如果希望得到YYYYMMDD的格式
SimpleDateFormat sy1=new SimpleDateFormat("yyyyMMDD");
String dateFormat=sy1.format(date);
//如果希望分开得到年,月,日
SimpleDateFormat sy=new SimpleDateFormat("yyyy");
SimpleDateFormat sm=new SimpleDateFormat("MM");
SimpleDateFormat sd=new SimpleDateFormat("dd");
String syear=sy.format(date);
String smon=sm.format(date);
String sday=sd.format(date);
//String -> Date
String reportdate_str ="2005-10-01";
reportdate_str = reportdate_str + "00:00:00.0";
Date reportdate = java.sql.Timestamp.valueOf(reportdate_str);
时间->String
V_DATE = reportdate.toString();
->int、double、other
//int
Integer.parseInt(String s)
int i = Double.intValue();
Character.getNumericValue('a');
//double
(new Float(100.00f)).doubleValue();
Double.valueOf("32.1").doubleValue();
Double d = Double.parseDouble( s );
//other
byte b = Byte.parseByte( s );
short t = Short.parseShort( s );
long l = Long.parseLong( s );
Float f = Float.parseFloat( s );
工具类
com.alibaba.fastjson.util.TypeUtils
Method Summary | -
-|-|-
static void | addBaseClassMappings()
static void | addClassMapping(String className, Class clazz)
static
static List <FieldInfo>| computeGetters(Class clazz, Map
static Class<?>| loadClass(String className)