Mercurial Hosting > luan
comparison core/src/luan/modules/Time.luan @ 256:15122d724ce4
more Time functions
git-svn-id: https://luan-java.googlecode.com/svn/trunk@257 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Tue, 28 Oct 2014 01:59:35 +0000 |
parents | e0fb8a49e031 |
children | 9e0d4452e649 |
comparison
equal
deleted
inserted
replaced
255:e5ad26746c94 | 256:15122d724ce4 |
---|---|
37 end | 37 end |
38 | 38 |
39 function format(time,pattern) | 39 function format(time,pattern) |
40 return SimpleDateFormat.new(pattern).format(Date.new(time)) | 40 return SimpleDateFormat.new(pattern).format(Date.new(time)) |
41 end | 41 end |
42 | |
43 function on( year, month, day, hour, minute, second, millis ) | |
44 month = month - 1 | |
45 local cal = Calendar.getInstance() | |
46 cal.set( year, month, day, hour or 0, minute or 0, second or 0 ) | |
47 cal.set( Calendar.MILLISECOND, millis or 0 ) | |
48 return cal.getTimeInMillis() | |
49 end | |
50 | |
51 function parse( pattern, source ) | |
52 return SimpleDateFormat.new(pattern).parse(source).getTime() | |
53 end | |
54 |