| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package com.xpn.xwiki.plugin.jodatime; |
| 22 |
|
|
| 23 |
|
import java.util.Locale; |
| 24 |
|
|
| 25 |
|
import org.joda.time.DateTime; |
| 26 |
|
import org.joda.time.DateTimeZone; |
| 27 |
|
import org.joda.time.Duration; |
| 28 |
|
import org.joda.time.MutableDateTime; |
| 29 |
|
import org.joda.time.ReadableInstant; |
| 30 |
|
import org.joda.time.format.DateTimeFormat; |
| 31 |
|
import org.joda.time.format.DateTimeFormatter; |
| 32 |
|
import org.joda.time.format.ISODateTimeFormat; |
| 33 |
|
|
| 34 |
|
import com.xpn.xwiki.XWikiContext; |
| 35 |
|
import com.xpn.xwiki.api.Api; |
| 36 |
|
import com.xpn.xwiki.plugin.XWikiDefaultPlugin; |
| 37 |
|
import com.xpn.xwiki.plugin.XWikiPluginInterface; |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
@see |
| 45 |
|
|
| |
|
| 0% |
Uncovered Elements: 41 (41) |
Complexity: 20 |
Complexity Density: 0.95 |
|
| 46 |
|
public class JodaTimePlugin extends XWikiDefaultPlugin |
| 47 |
|
{ |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
private static final DateTimeFormatter ISO_DATE_FORMATTER = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC); |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
@param |
| 55 |
|
@param |
| 56 |
|
@param |
| 57 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 58 |
0 |
public JodaTimePlugin(String name, String className, XWikiContext context)... |
| 59 |
|
{ |
| 60 |
0 |
super(name, className, context); |
| 61 |
0 |
init(context); |
| 62 |
|
} |
| 63 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 64 |
0 |
@Override... |
| 65 |
|
public String getName() |
| 66 |
|
{ |
| 67 |
0 |
return "jodatime"; |
| 68 |
|
} |
| 69 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 70 |
0 |
@Override... |
| 71 |
|
public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context) |
| 72 |
|
{ |
| 73 |
0 |
return new JodaTimePluginApi((JodaTimePlugin) plugin, context); |
| 74 |
|
} |
| 75 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 76 |
0 |
@Override... |
| 77 |
|
public void init(XWikiContext context) |
| 78 |
|
{ |
| 79 |
0 |
super.init(context); |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
|
| 83 |
|
@see |
| 84 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 85 |
0 |
public DateTime getDateTime()... |
| 86 |
|
{ |
| 87 |
0 |
return new DateTime(); |
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
|
| 91 |
|
@see |
| 92 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 93 |
0 |
public DateTime getDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour,... |
| 94 |
|
int secondOfMinute, int millisOfSecond) |
| 95 |
|
{ |
| 96 |
0 |
return new DateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond); |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
|
| 100 |
|
@see |
| 101 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 102 |
0 |
public DateTime getDateTime(long instant)... |
| 103 |
|
{ |
| 104 |
0 |
return new DateTime(instant); |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
|
| 108 |
|
@see |
| 109 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 110 |
0 |
public MutableDateTime getMutableDateTime()... |
| 111 |
|
{ |
| 112 |
0 |
return new MutableDateTime(); |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
|
| 116 |
|
@see |
| 117 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 118 |
0 |
public MutableDateTime getMutableDateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay,... |
| 119 |
|
int minuteOfHour, int secondOfMinute, int millisOfSecond) |
| 120 |
|
{ |
| 121 |
0 |
return new MutableDateTime(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute, |
| 122 |
|
millisOfSecond); |
| 123 |
|
} |
| 124 |
|
|
| 125 |
|
|
| 126 |
|
@see |
| 127 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 128 |
0 |
public MutableDateTime getMutableDateTime(long instant)... |
| 129 |
|
{ |
| 130 |
0 |
return new MutableDateTime(instant); |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
@see |
| 135 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 136 |
0 |
public DateTimeFormatter getDateTimeFormatterForPattern(String pattern, XWikiContext context)... |
| 137 |
|
{ |
| 138 |
0 |
return DateTimeFormat.forPattern(pattern).withLocale((Locale) context.get("locale")); |
| 139 |
|
} |
| 140 |
|
|
| 141 |
|
|
| 142 |
|
@see |
| 143 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 144 |
0 |
public DateTimeFormatter getDateTimeFormatterForStyle(String style, XWikiContext context)... |
| 145 |
|
{ |
| 146 |
0 |
return DateTimeFormat.forStyle(style).withLocale((Locale) context.get("locale")); |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
|
| 150 |
|
@see |
| 151 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 152 |
0 |
public DateTimeZone getServerTimezone()... |
| 153 |
|
{ |
| 154 |
0 |
return DateTimeZone.getDefault(); |
| 155 |
|
} |
| 156 |
|
|
| 157 |
|
|
| 158 |
|
@see |
| 159 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 160 |
0 |
public DateTimeZone getUTCTimezone()... |
| 161 |
|
{ |
| 162 |
0 |
return DateTimeZone.UTC; |
| 163 |
|
} |
| 164 |
|
|
| 165 |
|
|
| 166 |
|
@see |
| 167 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 168 |
0 |
public DateTimeZone getTimezone(String locationOrOffset)... |
| 169 |
|
{ |
| 170 |
0 |
return DateTimeZone.forID(locationOrOffset); |
| 171 |
|
} |
| 172 |
|
|
| 173 |
|
|
| 174 |
|
@see |
| 175 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 176 |
0 |
public DateTimeZone getTimezone(int offsetHours)... |
| 177 |
|
{ |
| 178 |
0 |
return DateTimeZone.forOffsetHours(offsetHours); |
| 179 |
|
} |
| 180 |
|
|
| 181 |
|
|
| 182 |
|
@see |
| 183 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 184 |
0 |
public DateTimeZone getTimezone(int offsetHours, int offsetMinutes)... |
| 185 |
|
{ |
| 186 |
0 |
return DateTimeZone.forOffsetHoursMinutes(offsetHours, offsetMinutes); |
| 187 |
|
} |
| 188 |
|
|
| 189 |
|
|
| 190 |
|
@see |
| 191 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 192 |
0 |
public Duration getDuration(long millis)... |
| 193 |
|
{ |
| 194 |
0 |
return new Duration(millis); |
| 195 |
|
} |
| 196 |
|
|
| 197 |
|
|
| 198 |
|
@see |
| 199 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 200 |
0 |
public Duration getDuration(ReadableInstant from, ReadableInstant to)... |
| 201 |
|
{ |
| 202 |
0 |
return new Duration(from, to); |
| 203 |
|
} |
| 204 |
|
|
| 205 |
|
|
| 206 |
|
@return |
| 207 |
|
@since |
| 208 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 209 |
0 |
public DateTimeFormatter getISODateTimeFormatter()... |
| 210 |
|
{ |
| 211 |
0 |
return ISO_DATE_FORMATTER; |
| 212 |
|
} |
| 213 |
|
} |