比如说 我是 123456
现在取 34两个数字怎么取
类似于subString 的功能

解决方案 »

  1.   

    public class Test {    public static void main(String[] args) {
            String str = "12345";
            String result = str.substring(2, 4);
            System.out.println(result);
        }
    }
      

  2.   

    public class SubStringTest { public static void main(String[] args) {
    int i =  123456;
    String s = Integer.toString(i);
    String subs = s.substring(2,4);
    System.out.println(subs);
    int afteri= Integer.parseInt(subs);
    }
    }
      

  3.   

    public class test{
    public static void main(String[] args){
    String str="123456";
    System.out.println("this is a test Program!");
    String str2 = str.charAt((str.length()/2)-1)+""+str.charAt(str.length()/2)+"";
    System.out.println(str2); }
    }
      

  4.   

    http://community.csdn.net/Expert/topic/4654/4654541.xml?temp=.9583246谁能 解决
      

  5.   

    哈哈  老毛同志不错
    问下...
    如何让取当前日期的前一天function init(){
    var today = new Date(); 
    year = today.getYear();
    month = today.getMonth();
    day = today.getDate();
    day = day;
    month = month+1;
    var sday = new String(day);
    var smonth = new String(month);
    if(smonth.length == 1)
    smonth = "0"+smonth;
    if(sday.length == 1 )
    sday = "0"+sday;
       form1.start_date.value = year+"-"+smonth+"-"+sday;
    }
    这个是取当前日期
      

  6.   

    public class Test {
        public static void main(String[] args) {
            String str = "12345";
            String result = str.substring(2, 4);
            System.out.println(result);
        }
    }
    这就是正解啊
      

  7.   

    给你个方法,//当前日期前几天或者后几天的日期 
    public static String afterNDay(int n){
            Calendar c=Calendar.getInstance();
            DateFormat df=new SimpleDateFormat("yyyy-MM-dd");
            c.setTime(new Date());
            c.add(Calendar.DATE,n);
            Date d2=c.getTime();
            String s=df.format(d2);
            return s;
        }
    另外:
    Date类中的getYear,getMonth,getDate方法,是不赞成用的方法