Skip to content

Commit c42f565

Browse files
authored
Merge pull request #38 from netplex/v2.2.2
V2.2.2
2 parents cb03bcb + 29dd02d commit c42f565

30 files changed

+99
-63
lines changed

.gitignore

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,7 @@
1-
2-
/json-smart/target
3-
/json-smart/.settings
4-
/json-smart/.classpath
5-
/json-smart/.project
6-
/parent/.project
7-
/parent/.settings
8-
/json-smart/src/test/java/asm
9-
/asm/.classpath
10-
/asm/.project
11-
/asm/.settings
12-
/asm/targetjson-smart-backport/.classpath
13-
json-smart-backport/.project
14-
json-smart-backport/.settings
15-
asm/target/
16-
json-smart-backport/target/
17-
json-smart/target/
18-
**/.project
1+
**/.classpath
2+
**/.idea/
3+
**/.project
4+
**/.settings/
5+
**/*.iml
196
**/bin
20-
*.classpath
21-
*.project
22-
*.prefs
7+
**/target

accessors-smart/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>net.minidev</groupId>
55
<artifactId>accessors-smart</artifactId>
6-
<version>1.1</version>
6+
<version>1.2</version>
77
<name>ASM based accessors helper used by json-smart</name>
88
<description>Java reflect give poor performance on getter setter an constructor calls, accessors-smart use ASM to speed up those calls.
99
</description>

accessors-smart/src/main/java/net/minidev/asm/ConvertDate.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.HashSet;
99
import java.util.Locale;
1010
import java.util.StringTokenizer;
11+
import java.util.TimeZone;
1112
import java.util.TreeMap;
1213

1314
public class ConvertDate {
@@ -40,6 +41,7 @@ private static Integer parseMonth(String s1) {
4041
static {
4142
voidData.add("CET");
4243
voidData.add("MEZ");
44+
voidData.add("PST");
4345
voidData.add("Uhr");
4446
voidData.add("h");
4547
voidData.add("pm");
@@ -118,6 +120,8 @@ public static Date convertToDate(Object obj) {
118120
return null;
119121
if (obj instanceof Date)
120122
return (Date) obj;
123+
if (obj instanceof Number)
124+
return new Date(((Number)obj).longValue());
121125
if (obj instanceof String) {
122126
StringTokenizer st = new StringTokenizer((String) obj, " -/:,.+");
123127
String s1 = "";
@@ -204,8 +208,12 @@ private static Date getMMDDYYYY(StringTokenizer st, String s1) {
204208
return null;
205209
s1 = st.nextToken();
206210
}
207-
cal.set(Calendar.YEAR, getYear(s1));
208-
211+
if (s1.length() == 4)
212+
cal.set(Calendar.YEAR, getYear(s1));
213+
else if (s1.length() == 2) {
214+
return addHour2(st, cal, s1);
215+
216+
}
209217
// /if (st.hasMoreTokens())
210218
// return null;
211219
// s1 = st.nextToken();
@@ -236,6 +244,10 @@ private static Date addHour(StringTokenizer st, Calendar cal, String s1) {
236244
return cal.getTime();
237245
s1 = st.nextToken();
238246
}
247+
return addHour2(st, cal, s1);
248+
}
249+
250+
private static Date addHour2(StringTokenizer st, Calendar cal, String s1) {
239251
cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(s1));
240252

241253
if (!st.hasMoreTokens())
@@ -273,13 +285,19 @@ private static Date addHour(StringTokenizer st, Calendar cal, String s1) {
273285
s1 = trySkip(st, s1, cal);
274286
// if (s1.equalsIgnoreCase("pm"))
275287
// cal.add(Calendar.HOUR_OF_DAY, 12);
288+
289+
if (s1.length() == 4 && Character.isDigit(s1.charAt(0)))
290+
cal.set(Calendar.YEAR, getYear(s1));
291+
276292
return cal.getTime();
277293
}
278294

279295
private static String trySkip(StringTokenizer st, String s1, Calendar cal) {
280296
while (voidData.contains(s1)) {
281297
if (s1.equalsIgnoreCase("pm"))
282298
cal.add(Calendar.HOUR_OF_DAY, 12);
299+
if (s1.equalsIgnoreCase("PST"))
300+
cal.setTimeZone(TimeZone.getTimeZone("PST"));
283301
if (!st.hasMoreTokens())
284302
return null;
285303
s1 = st.nextToken();

accessors-smart/src/test/java/net/minidev/asm/TestDateConvert.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public void testDateFR() throws Exception {
1717
tests.add("23 janvier 2012 13:42:12");
1818
tests.add("lundi 23 janvier 2012 13:42:12");
1919
tests.add("2012-01-23 13:42:12");
20+
tests.add("Thu Jan 23 13:42:12 PST 2012");
2021
//
2122
for (String testDate : tests) {
2223
Date parsed = null;

json-smart/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>net.minidev</groupId>
55
<artifactId>json-smart</artifactId>
6-
<version>2.2.1</version>
6+
<version>2.2.2</version>
77
<name>JSON Small and Fast Parser</name>
88
<description>
99
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.
@@ -47,7 +47,7 @@
4747
<dependency>
4848
<groupId>net.minidev</groupId>
4949
<artifactId>accessors-smart</artifactId>
50-
<version>1.1</version>
50+
<version>1.2</version>
5151
</dependency>
5252
</dependencies>
5353
<reporting>
@@ -95,7 +95,7 @@
9595
<!-- My old Is back -->
9696
<gpg.keyname>2C8DF6EC</gpg.keyname>
9797
<!-- <gpg.keyname>8E322ED0</gpg.keyname> -->
98-
<!-- <gpg.keyname>Uriel Chemouni (dev) <[email protected]></gpg.keyname> -->
98+
<!-- <gpg.keyname>Uriel Chemouni (dev) [email protected]</gpg.keyname> -->
9999
<!-- GPG Key ID to use for signing -->
100100
</properties>
101101
<build>
@@ -264,4 +264,4 @@
264264
</plugin>
265265
</plugins>
266266
</build>
267-
</project>
267+
</project>

json-smart/src/main/java/net/minidev/json/JSONArray.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
/**
2525
* A JSON array. JSONObject supports java.util.List interface.
2626
*
27-
* @author FangYidong<[email protected]>
28-
* @author Uriel Chemouni <[email protected]>
27+
* @author FangYidong &lt;[email protected]&gt;
28+
* @author Uriel Chemouni &lt;[email protected]&gt;
2929
*/
3030
public class JSONArray extends ArrayList<Object> implements List<Object>, JSONAwareEx, JSONStreamAwareEx {
3131
private static final long serialVersionUID = 9106884089231309568L;

json-smart/src/main/java/net/minidev/json/JSONAware.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Beans that support customized output of JSON text shall implement this
2020
* interface.
2121
*
22-
* @author FangYidong<[email protected]>
22+
* @author FangYidong &lt;[email protected]&gt;
2323
*/
2424
public interface JSONAware {
2525
/**

json-smart/src/main/java/net/minidev/json/JSONAwareEx.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* Adding compressions and formating features
2222
*
23-
* @author Uriel Chemouni <[email protected]>
23+
* @author Uriel Chemouni &lt;[email protected]&gt;
2424
*/
2525

2626
public interface JSONAwareEx extends JSONAware{

json-smart/src/main/java/net/minidev/json/JSONNavi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
* @since 1.0.9
2929
*
30-
* @author Uriel Chemouni <[email protected]>
30+
* @author Uriel Chemouni &lt;[email protected]&gt;
3131
*/
3232
public class JSONNavi<T> {
3333
private JsonReaderI<? super T> mapper;

json-smart/src/main/java/net/minidev/json/JSONObject.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
* A JSON object. Key value pairs are unordered. JSONObject supports
2626
* java.util.Map interface.
2727
*
28-
* @author FangYidong<[email protected]>
29-
* @author Uriel Chemouni <[email protected]>
28+
* @author FangYidong &lt;[email protected]&gt;
29+
* @author Uriel Chemouni &lt;[email protected]&gt;
3030
*/
3131
public class JSONObject extends HashMap<String, Object> implements JSONAware, JSONAwareEx, JSONStreamAwareEx {
3232
private static final long serialVersionUID = -503443796854799292L;
@@ -113,7 +113,6 @@ public String getAsString(String key) {
113113
/**
114114
* A Simple Helper cast an Object to an Number
115115
*
116-
* @see net.minidev.json.parser.JSONParserBase#parseNumber(String s)
117116
* @return a Number or null
118117
*/
119118
public Number getAsNumber(String key) {

0 commit comments

Comments
 (0)