package cn.jiangye.java;
import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Date;import java.util.Scanner;public class Well { //1. /*public static void main(String[] args){ good(); } public static void good(){ String st=""; boolean b=st.isEmpty(); System.out.println(b); }*/ //2. /*public static void main(String[] args){ good(); } public static void good(){ String scr="15651515461"; char b=scr.charAt(6); System.out.println(b); }*/ //3. /*public static void main(String[] args){ good(); }*/ /*public static void good(){ String string="ADSVAFGCC"; String b=string.toLowerCase(); System.out.println(b); }*/ //4. /*public static void good(){ String string="adfasdfgahg"; String str=string.toUpperCase(); System.out.println(str); }*/ //5. /*public static void good(){ StringBuffer buffer= new StringBuffer(); buffer.append("一花一世界"); buffer.replace(0, 5, "一叶一菩提"); System.out.println(buffer); }*/ //6. /*public static void good(){ String str="abcdefgh"; String str1=str.replace("abc", "xyz"); System.out.println(str1); }*/ //7. /*public static void good(){ String str=" agddga "; String str1=str.trim(); System.out.println(str1); }*/
闰年的方法
public static void main(String[] args) throws ParseException{ good(); } /*public static void good() throws ParseException{ SimpleDateFormat time=new SimpleDateFormat("yyyy-MM-dd"); Scanner sc=new Scanner(System.in); System.out.println("请输入年份"); int i=sc.nextInt();- Date date1=time.parse(i+"-1-31"); long ss=date1.getTime(); System.out.println(ss); Date date2=time.parse(i+"-3-1"); long ss1=date2.getTime(); System.out.println(ss1); long ss3=ss1-ss; long day=(ss3/1000/3600/24)-1; System.out.println(day); if(day==29) { System.out.println(i+"年是闰年"); }else if(day==28) { System.out.println(i+"年是平年"); } }*/ //活了多少天 public static void good() throws ParseException { Scanner sc=new Scanner(System.in); String i=sc.next(); Date date=new Date(); long time1=date.getTime(); //定义日期格式 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); System.out.println("请输入您的出生日期:(格式为yyyy-MM-dd)"); Date date2=sdf.parse(i); long time2=date2.getTime(); long time3=time1-time2; long day=time3/1000/3600/24; System.out.println("您共生存了:"+day+"天"); }}