Tag: String method returns the CAL sys between the XXX COM post
classTest { Public Static voidMain (string[] args)throwsparseexception {Date Date=NewDate (); SimpleDateFormat SDF=NewSimpleDateFormat ("Yyyy-mm-dd"); //After method determines whether the date is after the date parameterSystem.out.println (The After () method uses: current date "+ Sdf.format (date) +" Whether after 2018-01-01: "+ date.after (sdf.parse (" 2018-01-01 "))); System.out.println (The After () method uses: current date "+ Sdf.format (date) +" Whether after 2018-03-03: "+ date.after (sdf.parse (" 2018-03-03 "))); //before () method to determine whether the date is before the date parameterSystem.out.println (The Before () method uses: current date "+ Sdf.format (date) +" Whether before 2018-01-01: "+ Date.before (sdf.parse (" 2018-01-01 "))); System.out.println (The Before () method uses: current date "+ Sdf.format (date) +" Whether before 2018-03-03: "+ Date.before (sdf.parse (" 2018-03-03 "))); Date Dateclone= (Date) date.clone ();//Clone () method clones a new Date objectSystem.out.println ("Clone () method: Clone A new Date object:" +Sdf.format (Dateclone)); //the CompareTo () method is used for comparison of two dates, date equals date//parameter, returns a value that is less than 0 if it is earlier than the date parameter, and returns a value greater than 0 after the date parameter is returned 0System.out.println ("CompareTo () method used: The current date is compared to itself:" +Date.compareto (date)); System.out.println ("CompareTo () method used: Current Date" + Sdf.format (date) + "compared to 2018-01-01:" + Date.compareto (sdf.parse ("2018-01-01"))); System.out.println ("CompareTo () method used: Current Date" + Sdf.format (date) + "compared to 2018-03-03:" + Date.compareto (sdf.parse ("2018-03-03"))); //getYear () method returns the specified date is the first year since 1900System.out.println ("GetHours () method used: The current date is from 1900 onwards" + date.getyear () + "year"); //the GetMonth () method returns a number that represents the month, 0-11, 0 for JanuarySystem.out.println ("GetHours () method used: Current date is this year" + (Date.getmonth () + 1) + "Month"); //getDate () returns the day ordinal of the month specifiedSystem.out.println ("GetDate () method used: The current date is the first day of the month:" +date.getdate ()); //GetDay () returns the day of the week when the specified date isSystem.out.println ("GetDay () method used: The current date is the day of the week:" +date.getday ()); //the GetHours () method returns the number of hours that the specified date is the daySystem.out.println ("GetHours () method used: Current date is today's" + date.gethours () + "hours"); //the Getminutes () method returns the number of minutes that the specified date is the hour 0-59System.out.println ("getminutes () method used: Current hour elapsed" + date.getminutes () + "minutes"); //the Getminutes () method returns the number of minutes that the specified date is the hour 0-59System.out.println ("getseconds () method used: Current minute passes" + date.getseconds () + "seconds"); //GetTime () method, which returns the number of milliseconds since January 1, 1970 00:00:00 GMTSystem.out.println ("GetTime () method," +date.gettime () + "milliseconds" since January 1, 1970 00:00:00 GMT)); System.out.println ("There is also a series of setxxx () methods associated with the Get method to change the setting date, not to repeat--------------"); //A static method that returns the number of milliseconds since January 1, 1970 00:00:00 GMT, based on the date defined by the given parameterSystem.out.println ("The number of milliseconds since January 1, 1970 00:00:00 GMT:" +DATE.UTC (2017, 1, 7, 15, 1, 20)); //A static method that resolves its date according to the given stringSystem.out.println ("resolves the corresponding date according to the specified string:" +Date.parse (date.tostring ())); System.out.println ("ToString () returns the default time zone CST Date string:" +date.tostring ()); System.out.println ("toGMTString () returns the GMT date string:" +date.togmtstring ()); System.out.println ("toLocaleString () returns the date string under this time zone:" +date.tolocalestring ()); System.out.println ("The difference between the current TimeZone time and UTC, in minutes (China time zone is utc+8 so it is -480minutes)" +Date.gettimezoneoffset ()); }}
After () method used: Whether the current date 2018-02-07 is after 2018-01-01:trueAfter () method Use: current date 2018-02-07 whether after 2018-03-03:falsebefore () method used: current date 2018-02-07 whether before 2018-01-01:falsebefore () method used: current date 2018-02-07 whether before 2018-03-03:trueClone () method: Clones a new Date object:2018-02-07the CompareTo () method uses: The current date is compared to itself:0CompareTo () method used: current date 2018-02-07 compared to 2018-01-01:1CompareTo () method used: current date 2018-02-07 compared to 2018-03-03:1getHours () method use: The current date is the 118th year starting from 1900 GetHours () method usage: The current date is the 2nd month of the Year GetDate () method used: The current date is the day of the month:7GetDay () method use: The current date is the day of the week:3getHours () method use: The current date is the 15th hour of Today Getminutes () method used: Current hour after 16 minutes getseconds () method used: current minute after 30 seconds gettime () method, since January 1, 1970 00 :00:001517987790021 milliseconds since GMT this date is from January 1, 1970:Number of milliseconds since 00:00 GMT: 61444623680000resolves the corresponding date according to the specified string:1518038190000toString () returns the default time zone CST Date string: Wed Feb15:16:30 CST 2018togmtstring () Returns the GMT date string:7 Feb 2018 07:16:30gmttolocalestring () returns the date string under this time zone:2018-2-7 15:16:30The difference between the current TimeZone time and UTC, in minutes (China time Zone is UTC+8 so it is -480minutes)-480
Java.util.Date