The conversion between date (time) and String,int in JSP (online collection) __js

Source: Internet
Author: User
Tags numeric value

(1) Converting numbers to strings

int i = 7;
Double d = 13.56;
String str1,str2;
STR1 = integer.tostring (i);
STR2 = double.tostring (d);
After execution, the str1 stored string is "7" and the STR2 string is "13.56".
(2) Converting a string to a numeric value

String str1 = "3532";
String str2 = "187.863";
Integer m;
Double N;
m = integer.valueof (STR1); Converts a string type to an integer type
n = integer.valueof (str2); Converts a string type to a double type
int i = M.intvalue (); Converts an integer type to an int type
Double d = n.doublevalue ();
After execution, the integer variable i is 3532, and the floating-point variable is 187.863

(3) The 2nd way to convert from a string to a numeric value

String str1 = "3532";
String str2 = "187.863";

int i = Integer.praseint (STR1);
Double d = double.prasedouble (STR2);

After execution, the integer variable i is 3532, and the floating-point variable D is 187.863

(4) Date type conversion

Converts a string to a date type
Import Java.sql.Date;
Date date = new Date (0);
Date.valueof ("1983-09-09");
Converts a date type to a string type
Import Java.sql.Date;
Date date = new Date (0);
Date.valueof ("1983-09-09"). ToString ();

(5) int turns into integer

int i = 0;
Integer temp = new Integer (i);

Related Article

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.