|
6 | 6 |
|
7 | 7 | import org.joda.time.DateTime; |
8 | 8 | import org.joda.time.DateTimeUtils; |
| 9 | +import org.joda.time.LocalDate; |
| 10 | +import org.joda.time.LocalTime; |
9 | 11 | import org.junit.Ignore; |
10 | 12 | import org.junit.Test; |
11 | 13 | import org.slf4j.Logger; |
12 | 14 | import org.slf4j.LoggerFactory; |
13 | 15 |
|
14 | 16 | import cn.com.ttblog.ssmbootstrap_table.util.JodaTimeUtil; |
15 | 17 |
|
| 18 | +/** |
| 19 | + * LocalDate - date without time |
| 20 | + LocalTime - time without date |
| 21 | + Instant - an instantaneous point on the time-line |
| 22 | + DateTime - full date and time with time-zone |
| 23 | + DateTimeZone - a better time-zone |
| 24 | + Duration and Period - amounts of time |
| 25 | + Interval - the time between two instants |
| 26 | + A comprehensive and flexible formatter-parser |
| 27 | + */ |
16 | 28 | //@Ignore |
17 | 29 | public class TestJodaTime { |
18 | 30 | Logger log = LoggerFactory.getLogger(this.getClass()); |
@@ -121,4 +133,22 @@ public void parse(){ |
121 | 133 | public void getTimeStamp(){ |
122 | 134 | System.out.println("timestamp:"+System.currentTimeMillis()); |
123 | 135 | } |
| 136 | + |
| 137 | + @Test |
| 138 | + public void test() { |
| 139 | + LocalDate localDate = new LocalDate(); |
| 140 | + System.out.println("localDate:" + localDate); |
| 141 | + System.out.println("localDate.toDate():" + localDate.toDate()); |
| 142 | + LocalTime localTime=new LocalTime(); |
| 143 | + System.out.println("localTime:"+localTime); |
| 144 | + System.out.println("localTime.toDateTimeToday():"+localTime.toDateTimeToday()); |
| 145 | + LocalTime minTime=new LocalTime(0,0,0,0); |
| 146 | + LocalTime maxTime=new LocalTime(23,59,59,59); |
| 147 | + System.out.println("maxTime:"+maxTime); |
| 148 | + System.out.println("maxTime:"+maxTime.toDateTimeToday()); |
| 149 | + System.out.println("昨天的时间从:"+minTime.toDateTimeToday().plusDays(-1)+"到:"+maxTime.toDateTimeToday().plusDays(-1)); |
| 150 | + DateTime d1=new DateTime(); |
| 151 | + DateTime d2=new DateTime().plusMinutes(2); |
| 152 | + System.out.println("d2.compareTo(d1):"+d2.compareTo(d1)); |
| 153 | + } |
124 | 154 | } |
0 commit comments