package day06; /****** Demo of the Math class* Math class:* The 1,math class is final* The construction method of 2,math is private (cannot be manually new)* The method provided by 3,math is static (all can be called)* Common methods:* ABS: Absolute Value* sqrt: square root* Pow(double A, double b) A's power of B* Log Natural logarithm* exp e is the base index* MAX (double A, double b) two numbers for maximum value* min(double A, double b) Two number to find the minimum value* Random returns 0.0 to 1.0* Long round (double a) double type data A convert long, (rounded)* Todegrees (double angrad) radian ---"angle* Toradians (double angdeg) angle ---> radians * * @author Yw.wang * */public class Test08 { Public static void main (string[] args) { Double result =math. ABS ( -123);System. Out. println (result); double result2 =math. todegrees (2*math. PI);System. Out. println (RESULT2); }}
Date Class--------------------------------------------
Eeee is the week, MM is the month, DD is the day, YYYY is the year, the number of characters determines the date is in line with the format such as: Pass "ee-mm-dd-yyyy" will show "Friday-02-07-2009"Public Date Parse (string source) (in the Date format Class) resolves the format of a string time,Convert a string to a timeFor example:Date d = sdf2.parse ("2008/10/28 13:20:22")//Note that the format of the string must be consistent with the format (SDF2) you set
package day06; import java.text.SimpleDateFormat; import java.util.Date; /***** Date Class demo* Date class represents dates and times* Provides a partial method of operation date and time composition* One of the best applications for the date class is to get the system current time* Gets the current time is a long shaping data (long) Date d= new Date ();* @author Yw.wang **simpledateformat class* Function: Display format of finish date* As long as the format string "eeee-MM-DD-YYYY" is passed through to the SimpleDateFormat constructor* We can get the desired format and then call the Data.format (date date) method to get the desired format */public class Test09 { public static void main (string[] args) { date dd = new date ();System. Out. println (DD); SimpleDateFormat SF = new SimpleDateFormat ("Yyyy-mm-dd hh:mm:ss");System. Out. println (Sf.format (DD)); }}
Results:
From for notes (Wiz)
Math Class ++date Class