1,字符串如何转换为日期,比如字符串型2005-10-03,如何转换为日期型2005-10-03,引用那个包
2,日期型2005-10-03,又如何转换为字符串型2005-10-03,引用那个包
3,如何取得日期递减的方法:也就是说今天是2005-10-03,而点下一页时就为2005-10-02,再点下一页就为2005-10-01
4.字符型char如何定义,它可否与其它类型换,如果能如何转换
5.整型它可否与其它类型换,如果能如何转换谢谢各位

解决方案 »

  1.   

    /***************************************************************************
         * Name     toInt()
         * Function 把一个字符串转换为一个整数,不能转化则返回0。
         * @param   szStr   String
         * @Return  boolean
         * @Memo    default value is 30 (just for this servlet.)
         */
        private int toInt(String szStr) {
            int iTmp;        if (szStr == null) {
                return 0;
            }
            if (szStr.trim().equals("")) {
                return 0;
            }        try {
                iTmp = Integer.parseInt(szStr.trim());
                return iTmp;
            }
            catch (Exception e) {
                return 0;
            }
        }
      

  2.   

    日期转字符串:SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    Date d1 = new Date();
    System.out.println(df.format(d1));
      

  3.   

    int a=123;
    String b=a.toString();
      

  4.   

    日期:
    public String toString()
     Format a date in JDBC date escape format Returns: a String in yyyy-mm-dd format Overrides: toString in class Date  valueOf public static Date valueOf(String s)
     Convert a string in JDBC date escape format to a Date value Parameters: s - date in format "yyyy-mm-dd" Returns: corresponding Date
      

  5.   

    toString public abstract String toString()
     Returns the string value of this data element. Overrides: toString in class Object  type public abstract int type()
     Gets the type of data held by this object. Returns: the data type, one of: STRING, IMAGE, IMAGE_STRING, or a value >= USER_TYPE. See Also: STRING, IMAGE, IMAGE_STRING, USER_TYPE
      

  6.   

    日期和字符串相互转化主要靠java.text.SimpleDateFormat类
    日期转化为字符串:new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(date:Data)
    字符串转化为日期:new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(date:Data)
      

  7.   

    你可以看一下java.text这个Package下的类,里面可以达到你转换上的所有要求