java-The birthday __java of the identification number

Source: Internet
Author: User

Enter your own ID number, and this number to output their own birthday, month and year.

The code is as follows:

Package com.homework.lhh;

Import Java.util.Scanner;

public class Ex03 {
    String year;
    String month;
    String Day;
    static String ID;
    @SuppressWarnings ("resource") public
    void inputID () {
        Scanner sc = new Scanner (system.in);
        System.out.println ("Please enter your ID number:");
        id = sc.nextline ();
    }
    public void Cutid (String ID) {
        year = id.substring (6, 10);//intercept years
        month = id.substring (10, 12);//intercept month Day
        = Id.substring (12, 14);//Intercept Day
    } public
    String toString () {return
        "Your birthday is:" + year + "years" + month + "month" + da Y + "day." ";
    }
    public static void Main (string[] args) {
        Ex03 Peopleid = new Ex03 ();
        Peopleid.inputid ();
        Peopleid.cutid (ID);
        System.out.println (Peopleid.tostring ());
    }


Run the results as shown in figure:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.