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

📄 clock.java

📁 JAVA 数学程序库 提供常规的数值计算程序包
💻 JAVA
字号:
package jmathlib.toolbox.general;

import jmathlib.core.tokens.numbertokens.DoubleNumberToken;
import jmathlib.core.tokens.Token;
import jmathlib.core.tokens.OperandToken;
import jmathlib.core.functions.ExternalFunction;
import java.util.Date;
import java.util.Calendar;

/**External function to return the date and time*/
public class clock extends ExternalFunction
{
	/**@return the current date and time as a 6 by 1 vector containing
	[year month day hours minutes seconds]*/
	public OperandToken evaluate(Token[] operands)
	{
		Date now = new Date();
		
		Calendar calendarInst = Calendar.getInstance();
		calendarInst.setTime(now);
		
		double[][] datetime = new double[1][6];
		datetime[0][0]  = calendarInst.get(Calendar.YEAR);
		datetime[0][1]  = calendarInst.get(Calendar.MONTH) + 1;
		datetime[0][2]  = calendarInst.get(Calendar.DATE);
		
		datetime[0][3]  = calendarInst.get(Calendar.HOUR);
		datetime[0][4]  = calendarInst.get(Calendar.MINUTE);
		datetime[0][5]  = calendarInst.get(Calendar.SECOND);
		
		DoubleNumberToken result	= new DoubleNumberToken(datetime);
		return result;
	}
}

/*
@GROUP
general
@SYNTAX
clock()
@DOC
Returns the current date and time as a six element vector.
@EXAMPLES
clock() = [2,002, 6, 6, 5, 23, 34]
@NOTES
The variable should be given as a string containing the variable name.
@SEE
date, tic, toc, time
*/

⌨️ 快捷键说明

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