我的第一个问题,我很兴奋......自从上线以来我一直潜伏着并热爱这个网站,不过我为任何新手错误,格式化等道歉...
我正在尝试验证包含Java日期的字符串字段的格式.我们将以字符串形式接收日期,在将其解析为实际Date对象之前,我将验证其格式.传入的格式为YYYY-MM-DD格式.但是我坚持我的一个测试,如果我通过"1999-12-33"测试将失败(因为它应该是第33天)这个不完整的模式:
((19|20)\\d{2})-([1-9]|0[1-9]|1[0-2])-([12][0-9]|3[01])
但是,只要我在下面添加粗体字符,它就会通过测试(但不应该)
((19|20)\\d{2})-([1-9]|0[1-9]|1[0-2])-(0[1-9]|[1-9]|[12][0-9]|3[01])
*附加的注释,我知道我可以改变0[1-9]|[1-9]成0?[1-9],但我想打破一切下降到其最简单的格式,试图找出为什么这是行不通的.
这是我在一起完成所有不同日期场景的废料测试:
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class scrapTest {
public scrapTest() {
}
public static void main(String[] args) {
scrapTest a = new scrapTest();
boolean flag = a.verfiyDateFormat("1999-12-33");
}
private boolean verfiyDateFormat(String dateStr){
Pattern datePattern = Pattern.compile("((19|20)\\d{2})-([1-9]|0[1-9]|1[0-2])-(0[1-9]|[1-9]|[12][0-9]|3[01])");
Matcher dateMatcher = datePattern.matcher(dateStr);
if(!dateMatcher.find()){
System.out.println("Invalid date format!!! -> " + dateStr);
return false;
}
System.out.println("Valid date format.");
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
我已经编程了大约10年但是对Java非常新,所以请随意解释任何你认为合适的基本内容.
我正在构建一个小的选项卡式c#表单,我希望每个标签页都有一些共同的功能,特别是一个OK按钮和一个错误消息,并为特定的表单字段留出空间.
有没有其他人做过类似的事情,你是如何做到的?
在R6RS计划中抛出和捕获异常的标准方法是什么?我正在寻找适用于实现R6RS的任何版本的Scheme(不仅仅是PLT)的语法.
R6RS防护语法看起来可能适合该法案,但是有人能告诉我如何实际使用它的例子吗?
以下是带注释的示例:
class Program
{
// first version of structure
public struct D1
{
public double d;
public int f;
}
// during some changes in code then we got D2 from D1
// Field f type became double while it was int before
public struct D2
{
public double d;
public double f;
}
static void Main(string[] args)
{
// Scenario with the first version
D1 a = new D1();
D1 b = new D1();
a.f = b.f = 1; …Run Code Online (Sandbox Code Playgroud) 我尝试在文本框中显示日期时间值时收到错误:
我的代码是:
txtStartDate.Text = rdrGetUserInfo.IsDBNull(14) ? String.Empty : Convert.ToString(rdrGetUserInfo.GetString(14));
Run Code Online (Sandbox Code Playgroud)
错误消息是:ex.Message ="无法将'System.DateTime'类型的对象强制转换为'System.String'."
我有什么想法可以解决这个问题?
鉴于这种非常熟悉的原型构造模型:
function Rectangle(w,h) {
this.width = w;
this.height = h;
}
Rectangle.prototype.area = function() {
return this.width * this.height;
};
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释为什么呼叫new Rectangle(2,3)持续比Rectangle(2,3)没有'new'关键字呼叫快10倍?我会假设因为new会通过涉及原型来增加函数执行的复杂性,所以它会更慢.
例:
var myTime;
function startTrack() {
myTime = new Date();
}
function stopTrack(str) {
var diff = new Date().getTime() - myTime.getTime();
println(str + ' time in ms: ' + diff);
}
function trackFunction(desc, func, times) {
var i;
if (!times) times = 1;
startTrack();
for (i=0; i<times; i++) {
func();
}
stopTrack('(' + times …Run Code Online (Sandbox Code Playgroud) 我有一个Oracle表,其中的列类型为“ SYS.XMLTYPE”,并且存储过程正在执行插入操作:
(简洁版本):
PROCEDURE InsertXML
(
pXMLData IN LONG
)
IS
BEGIN
INSERT INTO MY_TABLE (XML_DATA) VALUES(pXMLData);
END InsertXML;
Run Code Online (Sandbox Code Playgroud)
我从C#代码中以“ OracleType.LongVarChar” 类型调用此sp 。
现在的问题是:如果xml的字符数少于4000个,则一切工作正常,但是如果使用的XML字符数超过4000个,则会出现以下错误:
ORA-20000: ORA-01461: can bind a LONG value only for insert into a LONG column
Run Code Online (Sandbox Code Playgroud)
我该如何处理?Thx 4个答案
我在SO用户页面上注意到所有网址都有rel ="nofollow me"(我想在我的网站上放置nofollow,所以我在这里查看看看是做什么的)."我"部分做了什么?
在Magento我正在创建一个自定义模块,并希望能够通过datetime列自动过滤,以便初始网格列表仅显示与"今天"日期相关的实体.
这是我的日期时间列:
$this->addColumn('ts', array(
'header' => $hlp->__('Activated'),
'align' => 'left',
'index' => 'ts',
'type' => 'datetime',
'width' => '160px',
));
Run Code Online (Sandbox Code Playgroud)
我认为应该有一种方法让我像这样添加一个过滤器到集合中:
$now = Mage::getModel('core/date')->timestamp(time());
$dateTime = date('m/d/y h:i:s', $now);
$collection = Mage::getModel('mymodule/items')->getCollection()
->addFieldToFilter('ts', $dateTime);
Run Code Online (Sandbox Code Playgroud)
但这不起作用?
我使用了错误的过滤器吗?数据库中的"ts"字段是"datetime"字段,但默认的magento"From:" - "To:"日期范围选择器不使用小时,分钟,秒.
有任何想法吗?
谢谢,特根