cmpptimestampformat.java

来自「采用JAVA开发」· Java 代码 · 共 37 行

JAVA
37
字号
package com.gctech.cmpp.util;

import java.text.SimpleDateFormat;
import java.text.DateFormat;
import java.util.Date;

/**
 * <p>Title: CNGP API</p>
 * <p>Description: 固网短信SP API</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: GCTECH</p>
 * @author 王红宝
 * @version 1.0
 */

public class CMPPTimestampFormat {
  static CMPPTimestampFormat singleton;
  private DateFormat format;
  CMPPTimestampFormat() {
    format = new SimpleDateFormat("MMddHHmmss");
  }
  public static CMPPTimestampFormat getInstance(){
    if ( singleton == null )
      singleton = new CMPPTimestampFormat();
    return singleton;
  }
  public String currentTimestamp(){
    return format.format(new Date());
  }
  public static void main(String[] args){
    String time = CMPPTimestampFormat.getInstance().currentTimestamp();
    System.out.println(time);
    int ntime = Integer.parseInt(time);
    System.out.println(ntime);
  }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?