注:如果使用JDK5.0的话,JVM会自动完成装包解包的。

1.Integer转换成int的方法

Integer i = new Integer(10); 
int k = i.intValue();
即Integer.intValue();

2.int转换成Integer

int i = 10;

Integer it = new Integer(i);

3.String转换成int的方法

String str = "10";  
Integer it = new Interger(str);

int i = it.intValue();

即:int i = Integer.intValue(string);

4.int转换成String

int i = 10;

(1)String s = String.valueOf(i);

(2)String s = Ingeger.toString(i);

(3)String s = "" + i;

5.String转换成Integer

String str = "10";

Integer it = Integer.valueOf(str);

6.Integer转换成String

Integer it = new Integer(10);

String str = it.toString();

7.String转换成BigDecimal

BigDecimal bd = new BigDecimal(str);

8.日期

Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH)+1;
int day = calendar.get(Calendar.DATE);

//获取今天的日期字符串
String today = java.text.DateFormat.getDateInstance().format(new java.util.Date());
//获取今天的日期
new java.sql.Date(System.currentTimeMillis());

int ,Intege,String 三者之间的转换的更多相关文章

  1. (转)CString,int,string,char*之间的转换

    CString,int,string,char*之间的转换http://www.cnblogs.com/greatverve/archive/2010/11/10/cstring-int-string ...

  2. MFC/C++/C中字符类型CString, int, string, char*之间的转换

    1 CString,int,string,char*之间的转换 string 转 CString CString.format("%s", string.c_str()); cha ...

  3. VC CString,int,string,char*之间的转换

    CString转string : CString strMfc = "test"; std::string strStr; strStr = strMfc.GetBuffer(); ...

  4. 做筛选遍历时遇到的json字符串、json对象、json数组 三者之间的转换问题

    这个是后台对登录用户以及筛选条件的操作 @Override public List<SdSdPer> listResults(String sidx, String sord) { try ...

  5. CString,string,char*之间的转换(转)

    这三种类型各有各的优点,比如CString比较灵活,是基于MFC常用的类型,安全性也最高,但可移植性最差.string是使用STL时必不可少的类型,所以是做工程时必须熟练掌握的:char*是从学习C语 ...

  6. wchar_t char string wstring 之间的转换

    wchar_t char string wstring 之间的转换 转:http://blog.csdn.net/lbd2008/article/details/8333583 在处理中文时有时需要进 ...

  7. 【转载】CString,string,char*之间的转换

    本文转自 <> 这三种类型各有各的优点,比如CString比较灵活,是基于MFC常用的类型,安全性也最高,但可移植性最差.string是使用STL时必不可少的类型,所以是做工程时必须熟练掌 ...

  8. Java基本数据类型、包装类与String类之间的转换

    一.基本数据类型与包装类之间的转换: import org.junit.Test; public class MainTest { /** * 基本数据类型与包装类之间的转换 */ @Test pub ...

  9. Java连载77-Integer常用方法、Integer、int、String三者相互转化、自动装箱、自动拆箱

    一.关于Integer中常用的方法 package com.bjpowernode.java_learning; ​ public class D77_1_ { public static void ...

随机推荐

  1. springadmin环境搭建

    一路走过来都是坑,记录下来以后避免在踩 springboot版本信息2.0.3 admin服务端 maven配置信息 <properties> <project.build.sour ...

  2. Omi框架学习之旅 - 获取DOM节点 及原理说明

    虽然绝大部分情况下,开发者不需要去查找获取DOM,但是还是有需要获取DOM的场景,所以Omi提供了方便获取DOM节点的方式. 这是官网的话,但是我一直都需要获取dom,对dom操作,所以omi提供的获 ...

  3. calico 原理分析

    1.calico没有使用CNI的网桥模式,calico的CNI插件还需要在host机器上为每个容器的veth pair配置一条路由规则.cni插件是calico与kubernetes对接部分. 2.B ...

  4. 监控虚拟机跟外部的tcp连接

    1.监控虚拟机跟外部的tcp连接,如果连接数超过阈值,就在FORWARD把ip DROP ,并且发送邮件 root@InternetGateway:~# cat /root/scripts/check ...

  5. Spring Boot 之 Profile 使用

    Spring Boot 之 Profile 使用 一个应用为了在不同的环境下工作,常常会有不同的配置,代码逻辑处理.Spring Boot 对此提供了简便的支持. 关键词: @Profile.spri ...

  6. Spring boot多模块(moudle)中的一个注入错误(Unable to start embedded container; nested exception is org)

    org.springframework.context.ApplicationContextException: Unable to start embedded container; nested ...

  7. Spring Boot(十八):使用 Spring Boot 集成 FastDFS

    上篇文章介绍了如何使用 Spring Boot 上传文件,这篇文章我们介绍如何使用 Spring Boot 将文件上传到分布式文件系统 FastDFS 中. 这个项目会在上一个项目的基础上进行构建. ...

  8. spring cloud服务提供与调用示例

    本文创建方式采用intellij IDEA  创建项目 1.创建基于Eureka的注册中心. 在打开项目中右键,选择new 选择moudle 然后下一步 输入要创建的项目的信息 选择web下面的web ...

  9. linux-shell-变量参数

    sxt1 的生命周期随着调起而生效,结束就消失 子进程和父进程的关系,

  10. E. Train Hard, Win Easy

    链接 [http://codeforces.com/contest/1043/problem/E] 题意 有n个人,每个人都有做出a,b题的分数,xi,yi,但是有些人是不能组队的,问你每个人和其他能 ...