How to resolve Java implementation ID number

ID number parsing, demo

/ ** 
 * ID number parsing Demo 
 * * / 
public class testarea { 
	public static void main (String [] args) { 
		System.out.println ( "test"); 
		// needs: identity card number, area code + birthday : year + month + day + gender 
		String cardNo = "61011320010505241X"; 
		String Area = ""; // before six, the national standard (GB GB) 
		// cut the string, ID 18, the inherent length 
		area = cardNo.substring (0,. 6); 
		System.out.println ( "the region encoding:" + area); 
		
		String Birthday = ""; 
		Birthday cardNo.substring = (. 6, 14); 
		System.out.println ( "Date of birth:" birthday +); 
		
		
		int year; // be taken from the intermediate variables birthday 
		year = Integer.parseInt (birthday.substring (0, 4)); // string converted into an integer 
		System.out.println (year); 
 
		int month the;
		the System.out .println (birthday.substring(4, 6));
		month = Integer.parseInt(birthday.substring(4, 6));
		System.out.println(month);
		
		int day;
		day = Integer.parseInt(birthday.substring(6));
		System.out.println(day);

		
		System.out.println("" + year + month + day);
		System.out.println("生日:"+year + "年" + month + "月" + day + "日");
		
		//倒数第二位
		String sex = "";
		sex = cardNo.substring( cardNo.length() -2 , cardNo.length() -1);
		System.out.println(sex);

	}
}

  

Guess you like

Origin www.cnblogs.com/lvxisha/p/11585343.html