读取系统时间后 怎么让他变成200806(只要年月)

来源:百度知道 编辑:UC知道 时间:2024/06/15 03:18:44
比如说系统时间是2008-08-19 怎么把他弄成200808(月份要两位表示)日期就不要了 jsp写 先谢谢 大大们帮忙
月份要两位的 比如说2008年1月 要写成200801 不是20081

package com.khan.datetime;

import java.util.*;
import java.text.*;

/**
* 时间编码类
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2006</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class SMPTime {

public static long getDateTime() {
Calendar now = null;
long date = 0;
try {
now = Calendar.getInstance();
date = now.get(Calendar.SECOND)
+ 100L * now.get(Calendar.MINUTE)
+ 10000L * now.get(Calendar.HOUR_OF_DAY)
+ 1000000L * now.get(Calendar.DATE)
+ 100000000L * (now.get(Calendar.MONTH) + 1)
+ 10000000000L * now.get(Calendar.YEAR);
} finally {
now = null;
}
return date;
}

public static String getSqlServerDate