EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.date.joda]

COVERAGE SUMMARY FOR SOURCE FILE [JodaDateService.java]

nameclass, %method, %block, %line, %
JodaDateService.java100% (1/1)93%  (14/15)95%  (118/124)95%  (20/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class JodaDateService100% (1/1)93%  (14/15)95%  (118/124)95%  (20/21)
iso8601SecondsDateFormat (): String 0%   (0/1)0%   (0/6)0%   (0/1)
<static initializer> 100% (1/1)100% (33/33)100% (4/4)
JodaDateService (): void 100% (1/1)100% (3/3)100% (1/1)
cDateFormat (): String 100% (1/1)100% (6/6)100% (1/1)
cDateFormat (Date): String 100% (1/1)100% (7/7)100% (1/1)
cDateParse (String): Date 100% (1/1)100% (5/5)100% (1/1)
fromSeconds (long): Date 100% (1/1)100% (7/7)100% (1/1)
iso8601DateFormat (): String 100% (1/1)100% (6/6)100% (1/1)
iso8601DateFormat (Date): String 100% (1/1)100% (7/7)100% (1/1)
iso8601DateParse (String): Date 100% (1/1)100% (11/11)100% (3/3)
iso8601SecondsDateFormat (Date): String 100% (1/1)100% (7/7)100% (1/1)
iso8601SecondsDateParse (String): Date 100% (1/1)100% (8/8)100% (2/2)
rfc822DateFormat (): String 100% (1/1)100% (6/6)100% (1/1)
rfc822DateFormat (Date): String 100% (1/1)100% (7/7)100% (1/1)
rfc822DateParse (String): Date 100% (1/1)100% (5/5)100% (1/1)

1/**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *   http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.jclouds.date.joda;
20 
21import static org.jclouds.date.internal.DateUtils.trimNanosToMillis;
22import static org.jclouds.date.internal.DateUtils.trimTZ;
23 
24import java.util.Date;
25import java.util.Locale;
26 
27import javax.inject.Singleton;
28 
29import org.jclouds.date.DateService;
30import org.joda.time.DateTime;
31import org.joda.time.DateTimeZone;
32import org.joda.time.format.DateTimeFormat;
33import org.joda.time.format.DateTimeFormatter;
34 
35/**
36 * 
37 * @author Adrian Cole
38 * @author James Murty
39 */
40@Singleton
41public class JodaDateService implements DateService {
42 
43   private static final DateTimeFormatter rfc822DateFormatter = DateTimeFormat.forPattern(
44            "EEE, dd MMM yyyy HH:mm:ss 'GMT'").withLocale(Locale.US).withZone(DateTimeZone.forID("GMT"));
45 
46   private static final DateTimeFormatter cDateFormatter = DateTimeFormat
47            .forPattern("EEE MMM dd HH:mm:ss '+0000' yyyy").withLocale(Locale.US).withZone(DateTimeZone.forID("GMT"));
48 
49   private static final DateTimeFormatter iso8601SecondsDateFormatter = DateTimeFormat.forPattern(
50            "yyyy-MM-dd'T'HH:mm:ss'Z'").withLocale(Locale.US).withZone(DateTimeZone.forID("GMT"));
51 
52   private static final DateTimeFormatter iso8601DateFormatter = DateTimeFormat.forPattern(
53            "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").withLocale(Locale.US).withZone(DateTimeZone.forID("GMT"));
54 
55   public final Date fromSeconds(long seconds) {
56      return new Date(seconds * 1000);
57   }
58 
59   public final String cDateFormat(Date dateTime) {
60      return cDateFormatter.print(new DateTime(dateTime));
61   }
62 
63   public final String cDateFormat() {
64      return cDateFormat(new Date());
65   }
66 
67   public final Date cDateParse(String toParse) {
68      return cDateFormatter.parseDateTime(toParse).toDate();
69   }
70 
71   public final String rfc822DateFormat(Date dateTime) {
72      return rfc822DateFormatter.print(new DateTime(dateTime));
73   }
74 
75   public final String rfc822DateFormat() {
76      return rfc822DateFormat(new Date());
77   }
78 
79   public final Date rfc822DateParse(String toParse) {
80      return rfc822DateFormatter.parseDateTime(toParse).toDate();
81   }
82 
83   public final String iso8601SecondsDateFormat(Date dateTime) {
84      return iso8601SecondsDateFormatter.print(new DateTime(dateTime));
85   }
86 
87   public final String iso8601SecondsDateFormat() {
88      return iso8601SecondsDateFormat(new Date());
89   }
90 
91   public final String iso8601DateFormat(Date date) {
92      return iso8601DateFormatter.print(new DateTime(date));
93   }
94 
95   public final String iso8601DateFormat() {
96      return iso8601DateFormat(new Date());
97   }
98 
99   public final Date iso8601DateParse(String toParse) {
100      toParse = trimTZ(toParse);
101      toParse = trimNanosToMillis(toParse);
102      return iso8601DateFormatter.parseDateTime(toParse).toDate();
103   }
104 
105   public final Date iso8601SecondsDateParse(String toParse) {
106      toParse = trimTZ(toParse);
107      return iso8601SecondsDateFormatter.parseDateTime(toParse).toDate();
108   }
109}

[all classes][org.jclouds.date.joda]
EMMA 2.0.5312 (C) Vladimir Roubtsov