锘??xml version="1.0" encoding="utf-8" standalone="yes"?>最近中文字幕mv免费高清在线,亚洲精华一区二区三区,黄页网址大全在线播放http://www.aygfsteel.com/mstar/category/29976.html鎼炶蔣浠跺紑鍙戝氨鍍忚寮哄ジ,濡傛灉涓嶈兘鍙嶆姉,灝變韓鍙楀畠鍚э紒zh-cnMon, 07 Sep 2009 09:39:37 GMTMon, 07 Sep 2009 09:39:37 GMT60[ZZ]Groovy Goodness: Date and Time Durations and the TimeCategoryhttp://www.aygfsteel.com/mstar/archive/2009/09/07/294145.html榛戠伒榛戠伒Mon, 07 Sep 2009 02:54:00 GMThttp://www.aygfsteel.com/mstar/archive/2009/09/07/294145.htmlhttp://www.aygfsteel.com/mstar/comments/294145.htmlhttp://www.aygfsteel.com/mstar/archive/2009/09/07/294145.html#Feedback0http://www.aygfsteel.com/mstar/comments/commentRss/294145.htmlhttp://www.aygfsteel.com/mstar/services/trackbacks/294145.htmlGroovy has some elegant ways to work with date and time values. One
of them is the support of durations. We can define a duration to denote
a certain time amount, like 7 days, 2 hours and 50 minutes. We can use
these durations to add or subtract them from date and time objects.
The TimeCategory provides an even Groovier way to work
with durations. We can use constructs like 7.days + 12.minutes to
create a duration. When we read this code it is just like reading
English text. Here is some sample code:
// We can assign later than the definition of the variables. int housenr
String streetname
(streetname, housenr) = ['Old Street', 42] assert42== housenr assert'Old Street'== streetname
// Return value of method can be assigned to multiple variables. def iAmHere() {
[29.20090, 12.90391]
}
def (coordX, coordY) = iAmHere() assert coordX ==29.20090 assert coordY ==12.90391
// More values than variables: extra values are ignored. def (a, b, c) = ['a', 'b', 'c', 'd'] assert'a'== a assert'b'== b assert'c'== c
// Less values than variables: variable is not set. def (x, y, z) = [100, 200] assert100== x assert200== y assert!z
]]>[ZZ]Groovy Goodness: the With Methodhttp://www.aygfsteel.com/mstar/archive/2009/09/07/294143.html榛戠伒榛戠伒Mon, 07 Sep 2009 02:51:00 GMThttp://www.aygfsteel.com/mstar/archive/2009/09/07/294143.htmlhttp://www.aygfsteel.com/mstar/comments/294143.htmlhttp://www.aygfsteel.com/mstar/archive/2009/09/07/294143.html#Feedback0http://www.aygfsteel.com/mstar/comments/commentRss/294143.htmlhttp://www.aygfsteel.com/mstar/services/trackbacks/294143.html to the java.lang.Object class. Let's see this with an example:
class Sample {
String username
String email
List<String> labels = []
def speakUp() { "I am $username" }
def addLabel(value) { labels << value }
}
def sb =new StringBuilder()
sb.with {
append 'Just another way to add '
append 'strings to the StringBuilder '
append 'object.'
}
assert'Just another way to add strings to the StringBuilder object.'== sb.toString()
// Another example as seen at //http://javajeff.blogspot.com/2008/11/getting-groovy-with-with.html def cal = Calendar.instance
cal.with {
clear()
set(YEAR, 2009)
set MONTH, SEPTEMBER
set DATE, 4
add DATE, 2
} assert'September 6, 2009'== cal.time.format('MMMM d, yyyy')