CSDN博客

img flyying

until常量

发表于2004/10/18 11:29:00  517人阅读

分类: struts

package jsswt.until;

import java.util.StringTokenizer;
import java.sql.Timestamp;
import laosun.database.DBO;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class Unitl {
  public Unitl() {
  }

  public static void main(String[] args) {
    Unitl u = new Unitl();
    System.out.println("" + u.get000(3));
    System.out.println(""+u.getTimeStamp());
  }

  public String getTimeStamp() {
    System.out.println(""+System.currentTimeMillis());
    Timestamp ts = new Timestamp(System.currentTimeMillis());
    String dateStr1 = ts.toString();
   System.out.println(dateStr1);
    StringTokenizer total = new StringTokenizer(dateStr1, "-");
    String year = total.nextToken();
    String month = total.nextToken();
    String third = total.nextToken();
    System.out.println("日(包含)以后是:"+third);
    String afterday = third.substring(2);
    StringTokenizer afterHour = new StringTokenizer(afterday, ":");
    StringTokenizer afterDay = new StringTokenizer(third, " ");
    String day = afterDay.nextToken();
    String hour = afterHour.nextToken();
    String minute = afterHour.nextToken();
    String afterSecond = afterHour.nextToken();
    String scecond = afterSecond.substring(0);
    StringTokenizer aftersecond = new StringTokenizer(scecond, ".");
    String second = aftersecond.nextToken();
    String result = year + month + day + hour + minute + second;
    String s1 = result.substring(0, 8);
    String s2 = result.substring(9);
    String YMDHMS = s1 + s2;
    return YMDHMS;
  }

  public String getCurMinTimeStamp() {
    String ret = this.getTimeStamp();
    ret = ret.substring(0, 8);
    ret = ret + "000001";
    return ret;
  }

  public String getCurMaxYear() {
    String ret = new String();
    ret = ret.substring(0, 4);
    String ret1 = ret.substring(3);
    ret = Integer.toString(Integer.parseInt(ret1) + 1);
    return ret;
  }

  public String getCurMaxMonth() {
    String ret = new String();
    return ret;
  }

  public String getCurMaxDay() {
    String ret = new String();
    return ret;
  }

  public String getCurMaxHour() {
    String ret = new String();
    return ret;
  }

  public String getCurMaxMinute() {
    String ret = new String();
    return ret;
  }

  public String getCurMaxScecond() {
    String ret = new String();
    return ret;
  }

  public String get000(int len) {
    String ret = new String();
    for (int i = 0; i < len; i++) {
      ret = ret + "0";
    }
    return ret;
  }

  public String getCurrentDateFormat() {
    java.text.DateFormat fmt = java.text.DateFormat.getDateTimeInstance();
    return fmt.format(new java.util.Date());
  }

  private String addDate(String closeDate, int monthNums) {
    String curr = closeDate.substring(5, 6); //格式是:2004-6-12 18:24:45,取第6个字符
    int month = Integer.parseInt(curr);
    if (month != 1 && month != 9) { //
      month = month + monthNums;
      if (month <= 12) {
        curr = Integer.toString(month);
        closeDate = closeDate.substring(0, 5) + curr + closeDate.substring(6);
      }
    }
    return closeDate;
  }
}

阅读全文
0 0

相关文章推荐

img
取 消
img