date要创建对象,int要要用Integer对象的静态方法得到

解决方案 »

  1.   

    String --> int 
    int n = Integer.parseInt(string);String --> float
    float f = Float.parseFloat(string)String --> Date
    Date date = DateFormat.parse(String source); 
    //Parses text from the beginning of the given string to produce a date.Date date = SimpleDateFormat.parse(String text, ParsePosition pos) 
    // Parses text from a string to produce a Date.
      

  2.   

    String to int :  Integer.parseInt(String);
    int to String :  String s = String.valueOf(int);
    String to float : Float.parseFloat(String);
    float to String : String s = String.valueOf(float);String to Date : 如把"2003-05-24 20:26:30"转换成Date,
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {
      Date date = df.parse("2003-05-24 20:26:30");
    } catch (ParseException pe) {}Date to String : 
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String date = df.format(new date());
      

  3.   

    要转换成的类.parse数据类型(源)