⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 times.java~1~

📁 野生动物系统的JAVA源码, 野生动物系统的JAVA源码
💻 JAVA~1~
字号:
package inout.util;

/**
 * <p>Title: the class for date and time</p>
 * <p>Description: the class can return current time ,date,time and date ,year
 * ,month,day,week,hour,minute,second,etc....</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: Chongqing Chana Information Technology Corp</p>
 * @author zengBo
 * @version 1.0
 */
import java.util.*;

public class Times {
  private static Calendar rightNow = Calendar.getInstance();

  /**
   * get current year
   * @return the year
   */
  public static String getCurYear() {
    return Integer.toString(rightNow.get(rightNow.YEAR));
  }

  /**
   * get current month
   * @return the month
   */
  public static String getCurMonth() {
    return Integer.toString(rightNow.get(rightNow.MONTH)+1);
  }

  /**
   * get current date
   * @return the date
   */
  public static String getCurDay() {
    return Integer.toString(rightNow.get(rightNow.DATE));
  }

  /**
   * get current time of hour
   * @return the hour
   */
  public static String getCurHour() {
    return Integer.toString(rightNow.get(rightNow.HOUR_OF_DAY));
  }

  /**
   * get current time of minute
   * @return the minute
   */
  public static String getCurMinute() {
    return Integer.toString(rightNow.get(rightNow.MINUTE));
  }

  /**
   * get current time of second
   * @return the second
   */
  public static String getCurSecond() {
    return Integer.toString(rightNow.get(rightNow.SECOND));
  }

  /**
   * get current week
   * @return the the day of week
   * SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, and SATURDAY.
   */
  public static String getCurWeek() {
    return Integer.toString(rightNow.get(rightNow.DAY_OF_WEEK) - 1);
  }

  /**
   * get current date
   * @return the date,such as 2003-5-6
   */
  public static String getCurDate() {
    return getCurYear() + "-" + getCurMonth() + "-" + getCurDay();
  }

  /**
   * get current date
   * @return the date,such as 2003年5月6日
   */
  public static String getCurChiDate() {
    return getCurYear() + "年" + getCurMonth() + "月" + getCurDay()+"日";
  }

  /**
   * get current time
   * @return the time,such as 11:20.50
   */
  public static String getCurTime() {
    return getCurHour() + ":" + getCurMinute() + ":" + getCurSecond();
  }

  /**
   * get current date and time
   * @return the date and time,such as 2003-5-6 11:20.50
   */
  public static String getCurDateAndTime() {
    return getCurDate() + " " + getCurTime();
  }

  public String getCur() {
  return Integer.toString(rightNow.get(rightNow.MINUTE));
}


  /**
   * the method for test
   * @param args
   */
  public static void main(String args[]) {
    Times ti=new Times();
    System.out.print(Times.getCurDateAndTime());
  }
}

⌨️ 快捷键说明

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