锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产亚洲精品无码专区,亚洲日韩中文字幕在线播放,亚洲综合色视频在线观看http://m.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://m.tkk7.com/mstar/archive/2009/09/07/294145.html榛戠伒榛戠伒Mon, 07 Sep 2009 02:54:00 GMThttp://m.tkk7.com/mstar/archive/2009/09/07/294145.htmlhttp://m.tkk7.com/mstar/comments/294145.htmlhttp://m.tkk7.com/mstar/archive/2009/09/07/294145.html#Feedback0http://m.tkk7.com/mstar/comments/commentRss/294145.htmlhttp://m.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://m.tkk7.com/mstar/archive/2009/09/07/294144.html榛戠伒榛戠伒Mon, 07 Sep 2009 02:52:00 GMThttp://m.tkk7.com/mstar/archive/2009/09/07/294144.htmlhttp://m.tkk7.com/mstar/comments/294144.htmlhttp://m.tkk7.com/mstar/archive/2009/09/07/294144.html#Feedback0http://m.tkk7.com/mstar/comments/commentRss/294144.htmlhttp://m.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://m.tkk7.com/mstar/archive/2009/09/07/294143.html榛戠伒榛戠伒Mon, 07 Sep 2009 02:51:00 GMThttp://m.tkk7.com/mstar/archive/2009/09/07/294143.htmlhttp://m.tkk7.com/mstar/comments/294143.htmlhttp://m.tkk7.com/mstar/archive/2009/09/07/294143.html#Feedback0http://m.tkk7.com/mstar/comments/commentRss/294143.htmlhttp://m.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://m.tkk7.com/mstar/archive/2008/03/11/gbk_to_utf8_use_groovy.html榛戠伒榛戠伒Tue, 11 Mar 2008 01:44:00 GMThttp://m.tkk7.com/mstar/archive/2008/03/11/gbk_to_utf8_use_groovy.htmlhttp://m.tkk7.com/mstar/comments/185259.htmlhttp://m.tkk7.com/mstar/archive/2008/03/11/gbk_to_utf8_use_groovy.html#Feedback2http://m.tkk7.com/mstar/comments/commentRss/185259.htmlhttp://m.tkk7.com/mstar/services/trackbacks/185259.html闃呰鍏ㄦ枃

榛戠伒 2008-03-11 09:44 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 黄色免费在线网站| 99久久亚洲综合精品成人网| 一区二区无码免费视频网站| 中国极品美軳免费观看| 亚洲AV日韩AV无码污污网站 | 色屁屁在线观看视频免费| 亚洲一级在线观看| 久久午夜夜伦鲁鲁片无码免费| 国产成人亚洲综合在线| 亚洲中文字幕乱码熟女在线| 亚洲视频在线观看免费视频| 成年女人毛片免费视频| 亚洲免费视频播放| 一级做a爰片久久毛片免费陪| 国产亚洲玖玖玖在线观看| 亚洲精品电影在线| 亚洲精品在线免费观看| 亚洲国产精品免费视频| 日本红怡院亚洲红怡院最新| 国产日韩成人亚洲丁香婷婷| 免费大片黄手机在线观看| 国产成人精品免费视频大全五级| 成人毛片免费观看视频大全| 在线观看的免费网站| 成年网站免费视频A在线双飞| 国产高清免费视频| 三年片免费观看大全国语| 国产福利免费视频| 国产99精品一区二区三区免费| 一级做α爱过程免费视频| jizz在线免费播放| 两个人看的www视频免费完整版| a在线视频免费观看在线视频三区 a毛片成人免费全部播放 | 久久精品国产亚洲AV无码偷窥| 亚洲影院在线观看| 1区1区3区4区产品亚洲| 亚洲精品亚洲人成在线观看麻豆 | 最近免费字幕中文大全视频| 91高清免费国产自产拍2021| 亚洲毛片免费观看| 成人无遮挡裸免费视频在线观看|