{"id":17,"date":"2014-05-30T10:36:40","date_gmt":"2014-05-30T02:36:40","guid":{"rendered":"http:\/\/iespandy.sinaapp.com\/?p=17"},"modified":"2014-05-30T10:36:40","modified_gmt":"2014-05-30T02:36:40","slug":"java%e7%b1%bb%e5%9e%8b%e8%bd%ac%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/www.espandy.com\/?p=17","title":{"rendered":"java\u7c7b\u578b\u8f6c\u6362"},"content":{"rendered":"<p>1\u5982\u4f55\u5c06\u5b57\u4e32 String \u8f6c\u6362\u6210\u6574\u6570 int?<\/p>\n<p>\u3000\u3000A. \u6709\u4e24\u4e2a\u65b9\u6cd5:<\/p>\n<p>\u3000\u30001). int i = Integer.parseInt([String]); \u6216<\/p>\n<p>\u3000\u3000i = Integer.parseInt([String],[int radix]);<\/p>\n<p>\u3000\u30002). int i = Integer.valueOf(my_str).intValue();<\/p>\n<p>\u3000\u3000\u6ce8: \u5b57\u4e32\u8f6c\u6210 Double, Float, Long \u7684\u65b9\u6cd5\u5927\u540c\u5c0f\u5f02.<\/p>\n<p>\u3000\u30002 \u5982\u4f55\u5c06\u6574\u6570 int \u8f6c\u6362\u6210\u5b57\u4e32 String ?<\/p>\n<p>\u3000\u3000A. \u6709\u53c1\u79cd\u65b9\u6cd5:<\/p>\n<p>\u3000\u30001.) String s = String.valueOf(i);<\/p>\n<p>\u3000\u30002.) String s = Integer.toString(i);<\/p>\n<p>\u3000\u30003.) String s = &#8220;&#8221; + i;<\/p>\n<p>\u3000\u3000\u6ce8: Double, Float, Long \u8f6c\u6210\u5b57\u4e32\u7684\u65b9\u6cd5\u5927\u540c\u5c0f\u5f02.<\/p>\n<p>\u3000\u3000\u8fd9\u662f\u4e00\u4e2a\u4f8b\u5b50,\u8bf4\u7684\u662fJAVA\u4e2d\u6570\u636e\u6570\u578b\u7684\u8f6c\u6362.\u4f9b\u5927\u5bb6\u5b66\u4e60\u5f15<\/p>\n<p>\u3000\u3000package cn.com.lwkj.erts.reGISter;<\/p>\n<p>\u3000\u3000import java.sql.Date;<\/p>\n<p>\u3000\u3000public class TypeChange {<\/p>\n<p>\u3000\u3000public TypeChange() {<\/p>\n<p>\u3000\u3000}<\/p>\n<p>\u3000\u3000\/\/change the string type to the int type<\/p>\n<p>\u3000\u3000public static int stringToInt(String intstr)<\/p>\n<p>\u3000\u3000{<\/p>\n<p>\u3000\u3000Integer integer;<\/p>\n<p>\u3000\u3000integer = Integer.valueOf(intstr);<\/p>\n<p>\u3000\u3000return integer.intValue();<\/p>\n<p>\u3000\u3000}<\/p>\n<p>\u3000\u3000\/\/change int type to the string type<\/p>\n<p>\u3000\u3000public static String intToString(int value)<\/p>\n<p>\u3000\u3000{<\/p>\n<p>\u3000\u3000Integer integer = new Integer(value);<\/p>\n<p>\u3000\u3000return integer.toString();<\/p>\n<p>\u3000\u3000}<\/p>\n<p>\u3000\u3000\/\/change the string type to the float type<\/p>\n<p>\u3000\u3000public static float stringToFloat(String floatstr)<\/p>\n<p>\u3000\u3000{<\/p>\n<p>\u3000\u3000Float floatee;<\/p>\n<p>\u3000\u3000floatee = Float.valueOf(floatstr);<\/p>\n<p>\u3000\u3000return floatee.floatValue();<\/p>\n<p>\u3000\u3000}<\/p>\n<p>\u3000\u3000\/\/change the float type to the string type<\/p>\n<p>\u3000\u3000public static String floatToString(float value)<\/p>\n<p>\u3000\u3000{<\/p>\n<p>\u3000\u3000Float floatee = new Float(value);<\/p>\n<p>\u3000\u3000return floatee.toString();<\/p>\n<p>\u3000\u3000}<\/p>\n<p>\u3000\u3000\/\/change the string type to the sqlDate type<\/p>\n<p>\u3000\u3000public static java.sql.Date stringToDate(String dateStr)<\/p>\n<p>\u3000\u3000{<\/p>\n<p>\u3000\u3000return java.sql.Date.valueOf(dateStr);<\/p>\n<p>\u3000\u3000}<\/p>\n<p>\u3000\u3000\/\/change the sqlDate type to the string type<\/p>\n<p>\u3000\u3000public static String dateToString(java.sql.Date datee)<\/p>\n<p>\u3000\u3000{<\/p>\n<p>\u3000\u3000return datee.toString();<\/p>\n<p>\u3000\u3000}<\/p>\n<p>\u3000\u3000public static void main(String[] args)<\/p>\n<p>\u3000\u3000{<\/p>\n<p>\u3000\u3000java.sql.Date day ;<\/p>\n<p>\u3000\u3000day = TypeChange.stringToDate(&#8220;2003-11-3&#8221;);<\/p>\n<p>\u3000\u3000String strday = TypeChange.dateToString(day);<\/p>\n<p>\u3000\u3000System.out.println(strday);<\/p>\n<p>\u3000\u3000}<\/p>\n<p>\u3000\u3000}<\/p>\n<p>\u3000\u3000JAVA\u4e2d\u5e38\u7528\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u51fd\u6570<\/p>\n<p>\u3000\u3000\u867d\u7136\u90fd\u80fd\u5728JAVA API\u4e2d\u627e\u5230\uff0c\u6574\u7406\u4e00\u4e0b\u505a\u4e2a\u5907\u4efd\u3002<\/p>\n<p>\u3000\u3000string->byte<\/p>\n<p>\u3000\u3000Byte static byte parseByte(String s)<\/p>\n<p>\u3000\u3000byte->string<\/p>\n<p>\u3000\u3000Byte static String toString(byte b)<\/p>\n<p>\u3000\u3000char->string<\/p>\n<p>\u3000\u3000Character static String to String (char c)<\/p>\n<p>\u3000\u3000string->Short<\/p>\n<p>\u3000\u3000Short static Short parseShort(String s)<\/p>\n<p>\u3000\u3000Short->String<\/p>\n<p>\u3000\u3000Short static String toString(Short s)<\/p>\n<p>\u3000\u3000String->Integer<\/p>\n<p>\u3000\u3000Integer static int parseInt(String s)<\/p>\n<p>\u3000\u3000Integer->String<\/p>\n<p>\u3000\u3000Integer static String tostring(int i)<\/p>\n<p>\u3000\u3000String->Long<\/p>\n<p>\u3000\u3000Long static long parseLong(String s)<\/p>\n<p>\u3000\u3000Long->String<\/p>\n<p>\u3000\u3000Long static String toString(Long i)<\/p>\n<p>\u3000\u3000String->Float<\/p>\n<p>\u3000\u3000Float static float parseFloat(String s)<\/p>\n<p>\u3000\u3000Float->String<\/p>\n<p>\u3000\u3000Float static String toString(float f)<\/p>\n<p>\u3000\u3000String->Double<\/p>\n<p>\u3000\u3000Double static double parseDouble(String s)<\/p>\n<p>\u3000\u3000Double->String<\/p>\n<p>\u3000\u3000Double static String toString(Double d)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u5982\u4f55\u5c06\u5b57\u4e32 String \u8f6c\u6362\u6210\u6574\u6570 int? \u3000\u3000A. \u6709\u4e24\u4e2a\u65b9\u6cd5: \u3000\u30001). int i = Inte [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-17","post","type-post","status-publish","format-standard","hentry","category-life"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.espandy.com\/index.php?rest_route=\/wp\/v2\/posts\/17","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.espandy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.espandy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.espandy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.espandy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17"}],"version-history":[{"count":1,"href":"https:\/\/www.espandy.com\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":18,"href":"https:\/\/www.espandy.com\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions\/18"}],"wp:attachment":[{"href":"https:\/\/www.espandy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.espandy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.espandy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}