我需要将分钟转换为小时,舍入到2位小数.我还需要在小数点后最多显示2个数字.所以如果我的分钟为650.那么小时应该是10.83
这是我到目前为止所拥有的:
Select round(Minutes/60.0,2) from ....
Run Code Online (Sandbox Code Playgroud)
但在这种情况下,如果我的分钟是630小时,那么我的分钟数是10万.但我只希望它为10.50(在四舍五入后).我该如何实现这一目标?
我有两个文本框接受它Start Date,并End Date分别在格式YYYY/MM/DD.
如果用户选择超过开始日期50天的结束日期,我需要提醒用户.
这是我到目前为止所拥有的:
var startDate = new Date(document.getElementsByName('MYSTARTDATE').value);
var endDate = new Date(document.getElementsByName('MYENDDATE').value);
if ((endDate - startDate) > 50)
{
alert('End date exceeds specification');
return false;
}
Run Code Online (Sandbox Code Playgroud)
举个例子,我选择开始日期为2012/01/22和结束日期为2012/02/29
startDate = 'Sun Jan 22 00:00:00 UTC +0530 2012'
endDate = 'Wed Feb 29 00:00:00 UTC +0530 2012'
Run Code Online (Sandbox Code Playgroud)
结果endDate - startDate是3283200000,而不是.38我做错了什么?
我有一个文本框,它接受格式为HH:mm的时间,条目应该只有24小时格式.对于所有无效条目,应显示常见消息"无效条目".
例如:
19:61 //INVALID
12:00am //INVALID
12***M //INVALID
06:00 //VALID
22:00 //VALID
5:45 //VALID
Run Code Online (Sandbox Code Playgroud)
所需的代码是Java.不熟悉正则表达式...所以需要你的想法.Thx提前!:)
String timeStr = getTimeBoxValue();
Run Code Online (Sandbox Code Playgroud) 我有一个整数数组列表。我的要求是确定arraylist是否在指定索引处存在一个元素。如果是,则应将值设置为该索引(使用set方法),否则应将值添加到该索引位置(使用add方法)
在我的Java代码中发现很难处理上述条件。请提供帮助。
这是我到目前为止的内容:
ArrayList<Integer> tempArray = new ArrayList<Integer>();
int counter = 0;
int tempValue = 0;
For LOOP -
if (//certain conditions are satisfied){
tempValue = calculateNewValue();
tempArray.add(counter, tempValue); //Need some logic here to determine if its a set or add method to be used
}
if (//some other conditions are satisfied){
counter++;
}
end For LOOP
Run Code Online (Sandbox Code Playgroud) 我需要验证包含时间的textBox条目.
时间应为HH:mm格式和24小时格式.
例如:
09:00, 21:00, 00:00, etc.,
Run Code Online (Sandbox Code Playgroud)
无效的条目:
2534, 090, *7&**, etc.,
Run Code Online (Sandbox Code Playgroud)
如果输入的时间是HHmm格式,那么我需要在条目中附加一个':'.
例如:
If textBox entry= 0930, it should be changed to 09:30
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止:
String textBoxVal = getTextBoxValue();
String colonCheck = ":";
if (!textBoxVal.contains(colonCheck)){
textBoxVal = textBoxVal.substring(0,2) + ":" + textBoxVal.substring(2,4);
}
Run Code Online (Sandbox Code Playgroud)
但很明显,这段代码并不适用于所有情况.
我对正则表达式不是很熟悉,所以对于如何使用Java中的正则表达式来实现这一点的任何帮助都会有所帮助!谢谢!
java ×3
regex ×2
validation ×2
arraylist ×1
date ×1
javascript ×1
replace ×1
rounding ×1
sql ×1
string ×1
subtraction ×1
time ×1