锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产亚洲精品无码专区,亚洲日韩中文字幕在线播放,亚洲综合色视频在线观看http://www.tkk7.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.tkk7.com/mstar/archive/2009/09/07/294145.html榛戠伒榛戠伒Mon, 07 Sep 2009 02:54:00 GMThttp://www.tkk7.com/mstar/archive/2009/09/07/294145.htmlhttp://www.tkk7.com/mstar/comments/294145.htmlhttp://www.tkk7.com/mstar/archive/2009/09/07/294145.html#Feedback0http://www.tkk7.com/mstar/comments/commentRss/294145.htmlhttp://www.tkk7.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:


import groovy.time.*
import org.codehaus.groovy.runtime.TimeCategory

// Define period of 2 years, 3 months, 15 days, 0 hours, 23 minutes, 2 seconds and 0 milliseconds.
def period = new DatumDependentDuration(231502320)
assert '2 years, 3 months, 15 days, 23 minutes, 2.000 seconds' == period.toString()
def year2000 
= new Date(10000)  // Jan 1, 2000
assert 'Mon Apr 15 00:23:02 UTC 2002' == (period + year2000).toString()

// Define time period of 5 hours, 54 minutes and 30 milliseconds.
def time = new TimeDuration(554030)
assert '5 hours, 54 minutes, 0.030 seconds' == time.toString()

use (TimeCategory) {
    
assert period.toString() == (2.years + 3.months + 15.days + 0.hour + 23.minutes + 2.seconds).toString()
    
assert time.toString() == (5.hours + 54.minutes + 30.milliseconds).toString()

    
// We can use period.from.now syntax.    
    def d1 = 1.week - 1.day
    def d2 
= new Date() + 6.days
    
assert d2.format('yyyy-MM-dd'== d1.from.now.toString()
    
    
// We can use period.ago syntax.
    def d3 = 3.days.ago
    def d4 
= new Date() - 3
    
assert d4.format('yyyy-MM-dd'== d3.toString()
}


榛戠伒 2009-09-07 10:54 鍙戣〃璇勮
]]>
[ZZ]Groovy Goodness: Multiple Assignmentshttp://www.tkk7.com/mstar/archive/2009/09/07/294144.html榛戠伒榛戠伒Mon, 07 Sep 2009 02:52:00 GMThttp://www.tkk7.com/mstar/archive/2009/09/07/294144.htmlhttp://www.tkk7.com/mstar/comments/294144.htmlhttp://www.tkk7.com/mstar/archive/2009/09/07/294144.html#Feedback0http://www.tkk7.com/mstar/comments/commentRss/294144.htmlhttp://www.tkk7.com/mstar/services/trackbacks/294144.html
// Assign and declare variables.
def (username, email) = ['mrhaki''email@host.com']
assert 'mrhaki' == username
assert 'email@host.com' == email

// We can assign later than the definition of the variables.
int housenr
String streetname
(streetname, housenr) 
= ['Old Street'42]
assert 42 == housenr
assert 'Old Street' == streetname

// Return value of method can be assigned to multiple variables.
def iAmHere() {
    [
29.2009012.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) = [100200]
assert 100 == x
assert 200 == y
assert !z



榛戠伒 2009-09-07 10:52 鍙戣〃璇勮
]]>
[ZZ]Groovy Goodness: the With Methodhttp://www.tkk7.com/mstar/archive/2009/09/07/294143.html榛戠伒榛戠伒Mon, 07 Sep 2009 02:51:00 GMThttp://www.tkk7.com/mstar/archive/2009/09/07/294143.htmlhttp://www.tkk7.com/mstar/comments/294143.htmlhttp://www.tkk7.com/mstar/archive/2009/09/07/294143.html#Feedback0http://www.tkk7.com/mstar/comments/commentRss/294143.htmlhttp://www.tkk7.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 sample 
= new Sample()
sample.with {
    username 
= 'mrhaki'
    email 
= 'email@host.com'
    println speakUp()  
// Output: I am mrhaki
    addLabel 'Groovy' 
    addLabel 
'Java'    
}
assert 2 == sample.labels.size()
assert 'Groovy' == sample.labels[0]
assert 'Java' == sample.labels[1]
assert 'mrhaki' == sample.username
assert 'email@host.com' == sample.email

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')



榛戠伒 2009-09-07 10:51 鍙戣〃璇勮
]]>
gbk_to_utf8http://www.tkk7.com/mstar/archive/2008/03/11/gbk_to_utf8_use_groovy.html榛戠伒榛戠伒Tue, 11 Mar 2008 01:44:00 GMThttp://www.tkk7.com/mstar/archive/2008/03/11/gbk_to_utf8_use_groovy.htmlhttp://www.tkk7.com/mstar/comments/185259.htmlhttp://www.tkk7.com/mstar/archive/2008/03/11/gbk_to_utf8_use_groovy.html#Feedback2http://www.tkk7.com/mstar/comments/commentRss/185259.htmlhttp://www.tkk7.com/mstar/services/trackbacks/185259.html闃呰鍏ㄦ枃

榛戠伒 2008-03-11 09:44 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 亚洲国产综合人成综合网站| 亚洲欧洲日产韩国在线| 久久免费观看国产精品88av| 亚洲日产2021三区在线| 国产乱弄免费视频| 午夜免费福利小电影| 亚洲欧美第一成人网站7777| 一本久久a久久精品亚洲| 97免费人妻无码视频| 免费国产黄网站在线观看动图| 亚洲AV无码专区在线播放中文| 啦啦啦www免费视频| 国产精品免费观看调教网| 亚洲国产欧美日韩精品一区二区三区| 久久久久亚洲AV无码专区桃色| 亚洲w码欧洲s码免费| 国产精品免费视频观看拍拍| 亚洲视频在线观看地址| 亚洲国产精品尤物yw在线| 日韩版码免费福利视频| 三级网站在线免费观看| 亚洲av无码兔费综合| 亚洲高清无在码在线无弹窗 | a级男女仿爱免费视频| 亚洲日本一线产区和二线 | yellow视频免费看| 亚洲午夜一区二区三区| 亚洲妇熟XXXX妇色黄| jizzjizz亚洲| 女人被男人桶得好爽免费视频 | 亚洲熟女精品中文字幕| 久久亚洲精品成人AV| 亚洲人成影院在线无码按摩店| 色视频色露露永久免费观看| 中国xxxxx高清免费看视频| a毛片久久免费观看| 日韩精品免费一线在线观看| 亚洲风情亚Aⅴ在线发布| 亚洲xxxxxx| 亚洲人成电影在线观看青青| 精品亚洲aⅴ在线观看|