Math Class ++date Class

Source: Internet
Author: User
Tags natural logarithm square root

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

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.