js 基础应用

2018-05-29  本文已影响0人  陆遥远

获取当前时间的前一个小时,其它配置可以修改3600000

 new Date(new Date().getTime() - 3600000);    

日期格式校验的正则表达式

"^([0-9]{4,}[-./](?:0?[0-9]|1[12])[-./](?:[012]?[0-9]|3[01])|([0-9]{4,}-(?:0?[0-9]|1[12])-(?:[012]?[0-9]|3[01]) (?:[01]?[0-9]|2[0-4]):(?:[0-5]?[0-9]|60):(?:[0-5]?[0-9]|60)))?$"

使用方式如下

/^([0-9]{4,}[-./](?:0?[0-9]|1[12])[-./](?:[012]?[0-9]|3[01])|([0-9]{4,}-(?:0?[0-9]|1[12])-(?:[012]?[0-9]|3[01]) (?:[01]?[0-9]|2[0-4]):(?:[0-5]?[0-9]|60):(?:[0-5]?[0-9]|60)))?$/.test('2017-12-30')

按照node命名规定:

命名

函数

注释

格式

对象和数据结构

final String  outputDir = ctxt.getOptions().getScratchDir().getAbsolutePath()
Options opts = ctxt.getOptions();
File scratchFile = opts.getScratchDir();
final String outputDir = scratchFile.getAbsolutePath();
String outputDir =  ctxt.getOutputDir();

错误处理

publc String getSomething throws NullPointException(){};

边界

上一篇 下一篇

猜你喜欢

热点阅读