DecimalFormat df = new DecimalFormat("00000");
SimpleDateFormat df = new SimpleDateFormat("yyyy年MM月dd日 HH点mm分ss秒"); 用他们对你的数据格式化
SimpleDateFormat df = new SimpleDateFormat("yyyy年MM月dd日 HH点mm分ss秒"); 用他们对你的数据格式化
解决方案 »
- java的反射小疑问,纯属好奇!
- java commons.net.ftp.FTPClient 报Could not parse response code
- java向linux终端输出信息(急)
- 图标文件放在项目包中的什么文件夹里面? 我直接放在包中,生成的JAR文件不能显示图标
- Daemon线程的疑问
- 请教一个非常基础的Applet的显示问题
- 怎么动态变量的命名?
- 新手上路,请指点一二,有关错误分析
- 在使用JFileChooser保存文件时的问题
- 哪有jbuilder mobileSet,Nokia Edition下载?
- 高分,为什么我不能调class????
- 一个有关Vector的简单问题。
我实现的具体程序为
import java.util.*;
import java.lang.Object;
import java.text.SimpleDateFormat;
public class URShift {
public static void main(String args[])
{
int i = 111;//目标int
long l = 1200378434;//目标long
Date currentTime= new Date();
String stri = pBinInt(i,10);
String strl = pBinLong(l,5);
String str3 = pBinDate(currentTime);
System.out.println(stri);
System.out.println(strl);
System.out.println(str3);
}static String pBinInt(int source,int count)
{
String stri =Integer.toString(source);
int j=Integer.toString(source).length();
if (j<count)
{
for (int i=count;i>=j;i--)
{
stri='0'+stri;
}
}
return stri;
}
static String pBinLong(long source,int count)
{
String stri =Long.toString(source);
int j=Long.toString(source).length();
if (j<count)
{ for (int i=count;i>=j;i--)
{
stri='0'+stri;
}
}
return stri;
}
static String pBinDate(Date source)
{
String stra="";
SimpleDateFormat simpleDate=new SimpleDateFormat("yyyy年MM月dd日 HH点mm分ss秒");
stra=simpleDate.format(source);
return stra;
}}