diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateSerializerDeserializer.java
index d4ce0e5..5f68522 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateSerializerDeserializer.java
@@ -23,7 +23,6 @@
 import edu.uci.ics.asterix.om.base.AMutableDate;
 import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
 import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -63,9 +62,7 @@
 
         long chrononTimeInMs = 0;
         try {
-            StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
-            charAccessor.reset(date, 0, date.length());
-            chrononTimeInMs = ADateParserFactory.parseDatePart(charAccessor);
+            chrononTimeInMs = ADateParserFactory.parseDatePart(date, 0, date.length());
         } catch (Exception e) {
             throw new HyracksDataException(e);
         }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateTimeSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateTimeSerializerDeserializer.java
index 93825b9..aadaac3 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateTimeSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADateTimeSerializerDeserializer.java
@@ -23,7 +23,6 @@
 import edu.uci.ics.asterix.om.base.AMutableDateTime;
 import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
 import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
@@ -66,27 +65,22 @@
 
         long chrononTimeInMs = 0;
         try {
-            StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
-            
-            charAccessor.reset(datetime, 0, datetime.length());
 
             // +1 if it is negative (-)
-            short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+            short timeOffset = (short) ((datetime.charAt(0) == '-') ? 1 : 0);
 
             timeOffset += 8;
             
-            if(charAccessor.getCharAt(timeOffset) != 'T'){
+            if(datetime.charAt(timeOffset) != 'T'){
                 timeOffset += 2;
-                if(charAccessor.getCharAt(timeOffset) != 'T'){
+                if(datetime.charAt(timeOffset) != 'T'){
                     throw new AlgebricksException(errorMessage + ": missing T");
                 }
             }
 
-            charAccessor.reset(datetime, 0, timeOffset);
-            chrononTimeInMs = ADateParserFactory.parseDatePart(charAccessor);
+            chrononTimeInMs = ADateParserFactory.parseDatePart(datetime, 0, timeOffset);
 
-            charAccessor.reset(datetime, timeOffset + 1, datetime.length() - timeOffset - 1);
-            chrononTimeInMs += ATimeParserFactory.parseTimePart(charAccessor);
+            chrononTimeInMs += ATimeParserFactory.parseTimePart(datetime, timeOffset + 1, datetime.length() - timeOffset - 1);
         } catch (Exception e) {
             throw new HyracksDataException(e);
         }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java
index 88e2ea5..2c38443 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ADurationSerializerDeserializer.java
@@ -8,7 +8,6 @@
 import edu.uci.ics.asterix.om.base.ADuration;
 import edu.uci.ics.asterix.om.base.AMutableDuration;
 import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
 import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -47,9 +46,7 @@
     public static void parse(String duration, DataOutput out) throws HyracksDataException {
         try {
             AMutableDuration aDuration = new AMutableDuration(0, 0);
-            StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
-            charAccessor.reset(duration, 0, duration.length());
-            ADurationParserFactory.parseDuration(charAccessor, aDuration);
+            ADurationParserFactory.parseDuration(duration, 0, duration.length(), aDuration);
 
             durationSerde.serialize(aDuration, out);
         } catch (Exception e) {
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
index 25ef597..5156bf9 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AIntervalSerializerDeserializer.java
@@ -24,7 +24,6 @@
 import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
 import edu.uci.ics.asterix.om.types.ATypeTag;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -93,8 +92,6 @@
         long chrononTimeInMsEnd = 0;
         try {
 
-            StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
-
             // the starting point for parsing (so for the accessor)
             int startOffset = 0;
             int endOffset, timeSeperatorOffsetInDatetimeString;
@@ -115,24 +112,22 @@
                 startOffset++;
             }
 
-            charAccessor.reset(interval, startOffset, endOffset - startOffset + 1);
-
             // +1 if it is negative (-)
-            timeSeperatorOffsetInDatetimeString = ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+            timeSeperatorOffsetInDatetimeString = ((interval.charAt(startOffset) == '-') ? 1 : 0);
 
             timeSeperatorOffsetInDatetimeString += 8;
 
-            if (charAccessor.getCharAt(timeSeperatorOffsetInDatetimeString) != 'T') {
+            if (interval.charAt(startOffset + timeSeperatorOffsetInDatetimeString) != 'T') {
                 timeSeperatorOffsetInDatetimeString += 2;
-                if (charAccessor.getCharAt(timeSeperatorOffsetInDatetimeString) != 'T') {
+                if (interval.charAt(startOffset + timeSeperatorOffsetInDatetimeString) != 'T') {
                     throw new AlgebricksException(errorMessage + ": missing T for a datetime value.");
                 }
             }
-            charAccessor.reset(interval, startOffset, timeSeperatorOffsetInDatetimeString);
-            chrononTimeInMsStart = ADateParserFactory.parseDatePart(charAccessor);
-            charAccessor.reset(interval, startOffset + timeSeperatorOffsetInDatetimeString + 1, endOffset
+
+            chrononTimeInMsStart = ADateParserFactory.parseDatePart(interval, startOffset, timeSeperatorOffsetInDatetimeString);
+
+            chrononTimeInMsStart += ATimeParserFactory.parseTimePart(interval, startOffset + timeSeperatorOffsetInDatetimeString + 1, endOffset
                     - (startOffset + timeSeperatorOffsetInDatetimeString + 1) + 1);
-            chrononTimeInMsStart += ATimeParserFactory.parseTimePart(charAccessor);
 
             // Interval End
             startOffset = commaIndex + 1;
@@ -145,24 +140,22 @@
                 startOffset++;
             }
 
-            charAccessor.reset(interval, startOffset, endOffset - startOffset + 1);
-
             // +1 if it is negative (-)
-            timeSeperatorOffsetInDatetimeString = ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+            timeSeperatorOffsetInDatetimeString = ((interval.charAt(startOffset) == '-') ? 1 : 0);
 
             timeSeperatorOffsetInDatetimeString += 8;
 
-            if (charAccessor.getCharAt(timeSeperatorOffsetInDatetimeString) != 'T') {
+            if (interval.charAt(startOffset + timeSeperatorOffsetInDatetimeString) != 'T') {
                 timeSeperatorOffsetInDatetimeString += 2;
-                if (charAccessor.getCharAt(timeSeperatorOffsetInDatetimeString) != 'T') {
+                if (interval.charAt(startOffset + timeSeperatorOffsetInDatetimeString) != 'T') {
                     throw new AlgebricksException(errorMessage + ": missing T for a datetime value.");
                 }
             }
-            charAccessor.reset(interval, startOffset, timeSeperatorOffsetInDatetimeString);
-            chrononTimeInMsEnd = ADateParserFactory.parseDatePart(charAccessor);
-            charAccessor.reset(interval, startOffset + timeSeperatorOffsetInDatetimeString + 1, endOffset
+
+            chrononTimeInMsEnd = ADateParserFactory.parseDatePart(interval, startOffset, timeSeperatorOffsetInDatetimeString);
+
+            chrononTimeInMsEnd += ATimeParserFactory.parseTimePart(interval, startOffset + timeSeperatorOffsetInDatetimeString + 1, endOffset
                     - (startOffset + timeSeperatorOffsetInDatetimeString + 1) + 1);
-            chrononTimeInMsEnd += ATimeParserFactory.parseTimePart(charAccessor);
         } catch (Exception e) {
             throw new HyracksDataException(e);
         }
@@ -179,8 +172,6 @@
         long chrononTimeInMsEnd = 0;
         try {
 
-            StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
-
             int startOffset = 0;
             int endOffset;
 
@@ -201,8 +192,7 @@
             }
 
             // Interval Start
-            charAccessor.reset(interval, startOffset, endOffset - startOffset + 1);
-            chrononTimeInMsStart = ATimeParserFactory.parseTimePart(charAccessor);
+            chrononTimeInMsStart = ATimeParserFactory.parseTimePart(interval, startOffset, endOffset - startOffset + 1);
 
             if (chrononTimeInMsStart < 0) {
                 chrononTimeInMsStart += GregorianCalendarSystem.CHRONON_OF_DAY;
@@ -220,8 +210,7 @@
                 endOffset--;
             }
 
-            charAccessor.reset(interval, startOffset, endOffset - startOffset + 1);
-            chrononTimeInMsEnd = ATimeParserFactory.parseTimePart(charAccessor);
+            chrononTimeInMsEnd = ATimeParserFactory.parseTimePart(interval, startOffset, endOffset - startOffset + 1);
 
             if (chrononTimeInMsEnd < 0) {
                 chrononTimeInMsEnd += GregorianCalendarSystem.CHRONON_OF_DAY;
@@ -243,7 +232,6 @@
         short tempStart = 0;
         short tempEnd = 0;
         try {
-            StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
 
             // the starting point for parsing (so for the accessor)
             int startOffset = 0;
@@ -265,8 +253,7 @@
                 startOffset++;
             }
 
-            charAccessor.reset(interval, startOffset, endOffset - startOffset + 1);
-            chrononTimeInMsStart = ADateParserFactory.parseDatePart(charAccessor);
+            chrononTimeInMsStart = ADateParserFactory.parseDatePart(interval, startOffset, endOffset - startOffset + 1);
 
             // Interval End
             startOffset = commaIndex + 1;
@@ -279,8 +266,7 @@
                 startOffset++;
             }
 
-            charAccessor.reset(interval, startOffset, endOffset - startOffset + 1);
-            chrononTimeInMsEnd = ADateParserFactory.parseDatePart(charAccessor);
+            chrononTimeInMsEnd = ADateParserFactory.parseDatePart(interval, startOffset, endOffset - startOffset + 1);
 
         } catch (Exception e) {
             throw new HyracksDataException(e);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ATimeSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ATimeSerializerDeserializer.java
index 26e8d7a..78baeed 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ATimeSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/ATimeSerializerDeserializer.java
@@ -8,7 +8,6 @@
 import edu.uci.ics.asterix.om.base.AMutableTime;
 import edu.uci.ics.asterix.om.base.ATime;
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.StringCharSequenceAccessor;
 import edu.uci.ics.asterix.om.types.BuiltinType;
 import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
 import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
@@ -51,9 +50,7 @@
         int chrononTimeInMs;
 
         try {
-            StringCharSequenceAccessor charAccessor = new StringCharSequenceAccessor();
-            charAccessor.reset(time, 0, time.length());
-            chrononTimeInMs = ATimeParserFactory.parseTimePart(charAccessor);
+            chrononTimeInMs = ATimeParserFactory.parseTimePart(time, 0, time.length());
         } catch (Exception e) {
             throw new HyracksDataException(e);
         }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateParserFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateParserFactory.java
index 7a335a7..c1fbcb2 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateParserFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateParserFactory.java
@@ -36,15 +36,12 @@
     @Override
     public IValueParser createValueParser() {
 
-        final CharArrayCharSequenceAccessor charArrayAccessor = new CharArrayCharSequenceAccessor();
-
         return new IValueParser() {
 
             @Override
             public void parse(char[] buffer, int start, int length, DataOutput out) throws HyracksDataException {
-                charArrayAccessor.reset(buffer, start, length);
                 try {
-                    out.writeInt((int) (parseDatePart(charArrayAccessor) / GregorianCalendarSystem.CHRONON_OF_DAY));
+                    out.writeInt((int) (parseDatePart(buffer, start, length) / GregorianCalendarSystem.CHRONON_OF_DAY));
                 } catch (IOException ex) {
                     throw new HyracksDataException(ex);
                 }
@@ -63,10 +60,9 @@
      * @return
      * @throws Exception
      */
-    public static <T> long parseDatePart(ICharSequenceAccessor<T> charAccessor)
+    public static long parseDatePart(String dateString, int start, int length)
             throws HyracksDataException {
 
-        int length = charAccessor.getLength();
         int offset = 0;
 
         int year = 0, month = 0, day = 0;
@@ -74,25 +70,25 @@
 
         boolean isExtendedForm = false;
 
-        if (charAccessor.getCharAt(offset) == '-') {
+        if (dateString.charAt(start + offset) == '-') {
             offset++;
             positive = false;
         }
 
-        if (charAccessor.getCharAt(offset + 4) == '-') {
+        if (dateString.charAt(start + offset + 4) == '-') {
             isExtendedForm = true;
         }
 
         if (isExtendedForm) {
-            if (charAccessor.getCharAt(offset + 4) != '-' || charAccessor.getCharAt(offset + 7) != '-') {
+            if (dateString.charAt(start + offset + 4) != '-' || dateString.charAt(start + offset + 7) != '-') {
                 throw new HyracksDataException("Missing dash in the date string as an extended form");
             }
         }
 
         // year
         for (int i = 0; i < 4; i++) {
-            if (charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9') {
-                year = year * 10 + charAccessor.getCharAt(offset + i) - '0';
+            if (dateString.charAt(start + offset + i) >= '0' && dateString.charAt(start + offset + i) <= '9') {
+                year = year * 10 + dateString.charAt(start + offset + i) - '0';
             } else {
                 throw new HyracksDataException("Non-numeric value in year field");
             }
@@ -107,8 +103,8 @@
 
         // month
         for (int i = 0; i < 2; i++) {
-            if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
-                month = month * 10 + charAccessor.getCharAt(offset + i) - '0';
+            if ((dateString.charAt(start + offset + i) >= '0' && dateString.charAt(start + offset + i) <= '9')) {
+                month = month * 10 + dateString.charAt(start + offset + i) - '0';
             } else {
                 throw new HyracksDataException("Non-numeric value in month field");
             }
@@ -122,8 +118,105 @@
 
         // day
         for (int i = 0; i < 2; i++) {
-            if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
-                day = day * 10 + charAccessor.getCharAt(offset + i) - '0';
+            if ((dateString.charAt(start + offset + i) >= '0' && dateString.charAt(start + offset + i) <= '9')) {
+                day = day * 10 + dateString.charAt(start + offset + i) - '0';
+            } else {
+                throw new HyracksDataException("Non-numeric value in day field");
+            }
+        }
+
+        if (day < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.DAY.ordinal()]
+                || day > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.DAY.ordinal()]) {
+            throw new HyracksDataException(dateErrorMessage + ": day " + day);
+        }
+
+        offset += 2;
+
+        if (!positive) {
+            year *= -1;
+        }
+
+        if (length > offset) {
+            throw new HyracksDataException("Too many chars for a date only value");
+        }
+        
+        if (!GregorianCalendarSystem.getInstance().validate(year, month, day, 0, 0, 0, 0)){
+            throw new HyracksDataException(dateErrorMessage);
+        }
+        
+        return GregorianCalendarSystem.getInstance().getChronon(year, month, day, 0, 0, 0, 0, 0);
+    }
+    
+    /**
+     * A copy-and-paste of {@link #parseDatePart(String, int, int)} but for a char array, in order
+     * to avoid object creation.
+     * 
+     * @param dateString
+     * @param start
+     * @param length
+     * @return
+     * @throws HyracksDataException
+     */
+    public static long parseDatePart(char[] dateString, int start, int length)
+            throws HyracksDataException {
+
+        int offset = 0;
+
+        int year = 0, month = 0, day = 0;
+        boolean positive = true;
+
+        boolean isExtendedForm = false;
+
+        if (dateString[start + offset] == '-') {
+            offset++;
+            positive = false;
+        }
+
+        if (dateString[start + offset + 4] == '-') {
+            isExtendedForm = true;
+        }
+
+        if (isExtendedForm) {
+            if (dateString[start + offset + 4] != '-' || dateString[start + offset + 7] != '-') {
+                throw new HyracksDataException("Missing dash in the date string as an extended form");
+            }
+        }
+
+        // year
+        for (int i = 0; i < 4; i++) {
+            if (dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9') {
+                year = year * 10 + dateString[start + offset + i] - '0';
+            } else {
+                throw new HyracksDataException("Non-numeric value in year field");
+            }
+        }
+
+        if (year < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.YEAR.ordinal()]
+                || year > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.YEAR.ordinal()]) {
+            throw new HyracksDataException(dateErrorMessage + ": year " + year);
+        }
+
+        offset += (isExtendedForm) ? 5 : 4;
+
+        // month
+        for (int i = 0; i < 2; i++) {
+            if ((dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9')) {
+                month = month * 10 + dateString[start + offset + i] - '0';
+            } else {
+                throw new HyracksDataException("Non-numeric value in month field");
+            }
+        }
+
+        if (month < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.MONTH.ordinal()]
+                || month > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.MONTH.ordinal()]) {
+            throw new HyracksDataException(dateErrorMessage + ": month " + month);
+        }
+        offset += (isExtendedForm) ? 3 : 2;
+
+        // day
+        for (int i = 0; i < 2; i++) {
+            if ((dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9')) {
+                day = day * 10 + dateString[start + offset + i] - '0';
             } else {
                 throw new HyracksDataException("Non-numeric value in day field");
             }
@@ -151,4 +244,100 @@
         return GregorianCalendarSystem.getInstance().getChronon(year, month, day, 0, 0, 0, 0, 0);
     }
 
+    /**
+     * A copy-and-paste of {@link #parseDatePart(String, int, int)} but for a byte array, in order
+     * to avoid object creation.
+     * 
+     * @param dateString
+     * @param start
+     * @param length
+     * @return
+     * @throws HyracksDataException
+     */
+    public static long parseDatePart(byte[] dateString, int start, int length)
+            throws HyracksDataException {
+
+        int offset = 0;
+
+        int year = 0, month = 0, day = 0;
+        boolean positive = true;
+
+        boolean isExtendedForm = false;
+
+        if (dateString[start + offset] == '-') {
+            offset++;
+            positive = false;
+        }
+
+        if (dateString[start + offset + 4] == '-') {
+            isExtendedForm = true;
+        }
+
+        if (isExtendedForm) {
+            if (dateString[start + offset + 4] != '-' || dateString[start + offset + 7] != '-') {
+                throw new HyracksDataException("Missing dash in the date string as an extended form");
+            }
+        }
+
+        // year
+        for (int i = 0; i < 4; i++) {
+            if (dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9') {
+                year = year * 10 + dateString[start + offset + i] - '0';
+            } else {
+                throw new HyracksDataException("Non-numeric value in year field");
+            }
+        }
+
+        if (year < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.YEAR.ordinal()]
+                || year > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.YEAR.ordinal()]) {
+            throw new HyracksDataException(dateErrorMessage + ": year " + year);
+        }
+
+        offset += (isExtendedForm) ? 5 : 4;
+
+        // month
+        for (int i = 0; i < 2; i++) {
+            if ((dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9')) {
+                month = month * 10 + dateString[start + offset + i] - '0';
+            } else {
+                throw new HyracksDataException("Non-numeric value in month field");
+            }
+        }
+
+        if (month < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.MONTH.ordinal()]
+                || month > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.MONTH.ordinal()]) {
+            throw new HyracksDataException(dateErrorMessage + ": month " + month);
+        }
+        offset += (isExtendedForm) ? 3 : 2;
+
+        // day
+        for (int i = 0; i < 2; i++) {
+            if ((dateString[start + offset + i] >= '0' && dateString[start + offset + i] <= '9')) {
+                day = day * 10 + dateString[start + offset + i] - '0';
+            } else {
+                throw new HyracksDataException("Non-numeric value in day field");
+            }
+        }
+
+        if (day < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.DAY.ordinal()]
+                || day > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.DAY.ordinal()]) {
+            throw new HyracksDataException(dateErrorMessage + ": day " + day);
+        }
+
+        offset += 2;
+
+        if (!positive) {
+            year *= -1;
+        }
+
+        if (length > offset) {
+            throw new HyracksDataException("Too many chars for a date only value");
+        }
+        
+        if (!GregorianCalendarSystem.getInstance().validate(year, month, day, 0, 0, 0, 0)){
+            throw new HyracksDataException(dateErrorMessage);
+        }
+        
+        return GregorianCalendarSystem.getInstance().getChronon(year, month, day, 0, 0, 0, 0, 0);
+    }
 }
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateTimeParserFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateTimeParserFactory.java
index b555c38..c95ac3a 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateTimeParserFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADateTimeParserFactory.java
@@ -36,32 +36,27 @@
     @Override
     public IValueParser createValueParser() {
 
-        final CharArrayCharSequenceAccessor charArrayAccessor = new CharArrayCharSequenceAccessor();
-
         return new IValueParser() {
 
             @Override
             public void parse(char[] buffer, int start, int length, DataOutput out) throws HyracksDataException {
                 long chrononTimeInMs = 0;
 
-                charArrayAccessor.reset(buffer, start, length);
-
-                short timeOffset = (short) ((charArrayAccessor.getCharAt(0) == '-') ? 1 : 0);
+                short timeOffset = (short) ((buffer[start] == '-') ? 1 : 0);
 
                 timeOffset += 8;
 
-                if (charArrayAccessor.getCharAt(timeOffset) != 'T') {
+                if (buffer[start + timeOffset] != 'T') {
                     timeOffset += 2;
-                    if (charArrayAccessor.getCharAt(timeOffset) != 'T') {
+                    if (buffer[start + timeOffset] != 'T') {
                         throw new HyracksDataException(dateTimeErrorMessage + ": missing T");
                     }
                 }
 
-                charArrayAccessor.reset(buffer, start, timeOffset);
-                chrononTimeInMs = ADateParserFactory.parseDatePart(charArrayAccessor);
+                chrononTimeInMs = ADateParserFactory.parseDatePart(buffer, start, timeOffset);
 
-                charArrayAccessor.reset(buffer, start + timeOffset + 1, length - timeOffset - 1);
-                chrononTimeInMs += ATimeParserFactory.parseTimePart(charArrayAccessor);
+                chrononTimeInMs += ATimeParserFactory.parseTimePart(buffer, start + timeOffset + 1, length - timeOffset
+                        - 1);
 
                 try {
                     out.writeLong(chrononTimeInMs);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java
index b176061..de5a6a1 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ADurationParserFactory.java
@@ -36,14 +36,12 @@
 
     @Override
     public IValueParser createValueParser() {
-        final CharArrayCharSequenceAccessor charArrayAccessor = new CharArrayCharSequenceAccessor();
         final AMutableDuration aMutableDuration = new AMutableDuration(0, 0);
         return new IValueParser() {
 
             @Override
             public void parse(char[] buffer, int start, int length, DataOutput out) throws HyracksDataException {
-                charArrayAccessor.reset(buffer, start, length);
-                parseDuration(charArrayAccessor, aMutableDuration);
+                parseDuration(buffer, start, length, aMutableDuration);
                 try {
                     out.writeInt(aMutableDuration.getMonths());
                     out.writeLong(aMutableDuration.getMilliseconds());
@@ -66,7 +64,7 @@
         SEC;
     };
 
-    public static <T> void parseDuration(ICharSequenceAccessor<T> charAccessor, AMutableDuration aDuration)
+    public static void parseDuration(String durationString, int start, int length, AMutableDuration aDuration)
             throws HyracksDataException {
 
         boolean positive = true;
@@ -74,21 +72,23 @@
         int value = 0, hour = 0, minute = 0, second = 0, millisecond = 0, year = 0, month = 0, day = 0;
         State state = State.NOTHING_READ;
 
-        if (charAccessor.getCharAt(offset) == '-') {
+        if (durationString.charAt(start + offset) == '-') {
             offset++;
             positive = false;
         }
 
-        if (charAccessor.getCharAt(offset++) != 'P') {
+        if (durationString.charAt(start + offset) != 'P') {
             throw new HyracksDataException(durationErrorMessage + ": Missing leading 'P'.");
         }
 
-        for (; offset < charAccessor.getLength(); offset++) {
-            if (charAccessor.getCharAt(offset) >= '0' && charAccessor.getCharAt(offset) <= '9') {
+        offset++;
+
+        for (; offset < length; offset++) {
+            if (durationString.charAt(start + offset) >= '0' && durationString.charAt(start + offset) <= '9') {
                 // accumulate the digit fields
-                value = value * 10 + charAccessor.getCharAt(offset) - '0';
+                value = value * 10 + durationString.charAt(start + offset) - '0';
             } else {
-                switch (charAccessor.getCharAt(offset)) {
+                switch (durationString.charAt(start + offset)) {
                     case 'Y':
                         if (state.compareTo(State.YEAR) < 0) {
                             year = value;
@@ -139,11 +139,276 @@
                     case '.':
                         if (state.compareTo(State.MILLISEC) < 0) {
                             int i = 1;
-                            for (; offset + i < charAccessor.getLength(); i++) {
-                                if (charAccessor.getCharAt(offset + i) >= '0'
-                                        && charAccessor.getCharAt(offset + i) <= '9') {
+                            for (; offset + i < length; i++) {
+                                if (durationString.charAt(start + offset + i) >= '0'
+                                        && durationString.charAt(start + offset + i) <= '9') {
                                     if (i < 4) {
-                                        millisecond = millisecond * 10 + (charAccessor.getCharAt(offset + i) - '0');
+                                        millisecond = millisecond * 10
+                                                + (durationString.charAt(start + offset + i) - '0');
+                                    } else {
+                                        throw new HyracksDataException(durationErrorMessage
+                                                + ": wrong MILLISECOND field.");
+                                    }
+                                } else {
+                                    break;
+                                }
+                            }
+                            offset += i;
+                            state = State.MILLISEC;
+                        } else {
+                            throw new HyracksDataException(durationErrorMessage + ": wrong MILLISECOND field.");
+                        }
+                    case 'S':
+                        if (state.compareTo(State.SEC) < 0) {
+                            second = value;
+                            state = State.SEC;
+                        } else {
+                            throw new HyracksDataException(durationErrorMessage + ": wrong SECOND field.");
+                        }
+                        break;
+                    default:
+                        throw new HyracksDataException(durationErrorMessage + ": wrong format for duration.");
+
+                }
+                value = 0;
+            }
+        }
+
+        if (state.compareTo(State.TIME) == 0) {
+            throw new HyracksDataException(durationErrorMessage + ": no time fields after time separator.");
+        }
+
+        short temp = 1;
+        if (!positive) {
+            temp = -1;
+        }
+
+        aDuration.setValue(temp * (year * 12 + month), temp
+                * (day * 24 * 3600 * 1000L + 3600 * 1000L * hour + 60 * minute * 1000L + second * 1000L + millisecond));
+
+    }
+
+    /**
+     * Copy-and-paste the code in {@link #parseDuration(String, int, int, AMutableDuration)} in order to eliminate
+     * object creation.
+     * 
+     * @param charAccessor
+     * @param start
+     * @param length
+     * @param aDuration
+     * @throws HyracksDataException
+     */
+    public static void parseDuration(char[] charAccessor, int start, int length, AMutableDuration aDuration)
+            throws HyracksDataException {
+
+        boolean positive = true;
+        int offset = 0;
+        int value = 0, hour = 0, minute = 0, second = 0, millisecond = 0, year = 0, month = 0, day = 0;
+        State state = State.NOTHING_READ;
+
+        if (charAccessor[start + offset] == '-') {
+            offset++;
+            positive = false;
+        }
+
+        if (charAccessor[start + offset] != 'P') {
+            throw new HyracksDataException(durationErrorMessage + ": Missing leading 'P'.");
+        }
+
+        offset++;
+
+        for (; offset < length; offset++) {
+            if (charAccessor[start + offset] >= '0' && charAccessor[start + offset] <= '9') {
+                // accumulate the digit fields
+                value = value * 10 + charAccessor[start + offset] - '0';
+            } else {
+                switch (charAccessor[start + offset]) {
+                    case 'Y':
+                        if (state.compareTo(State.YEAR) < 0) {
+                            year = value;
+                            state = State.YEAR;
+                        } else {
+                            throw new HyracksDataException(durationErrorMessage + ": wrong YEAR feild.");
+                        }
+                        break;
+                    case 'M':
+                        if (state.compareTo(State.TIME) < 0) {
+                            if (state.compareTo(State.MONTH) < 0) {
+                                month = value;
+                                state = State.MONTH;
+                            } else {
+                                throw new HyracksDataException(durationErrorMessage + ": wrong MONTH field.");
+                            }
+                        } else if (state.compareTo(State.MIN) < 0) {
+                            minute = value;
+                            state = State.MIN;
+                        } else {
+                            throw new HyracksDataException(durationErrorMessage + ": wrong MIN field.");
+                        }
+                        break;
+                    case 'D':
+                        if (state.compareTo(State.DAY) < 0) {
+                            day = value;
+                            state = State.DAY;
+                        } else {
+                            throw new HyracksDataException(durationErrorMessage + ": wrong DAY field");
+                        }
+                        break;
+                    case 'T':
+                        if (state.compareTo(State.TIME) < 0) {
+                            state = State.TIME;
+                        } else {
+                            throw new HyracksDataException(durationErrorMessage + ": wrong TIME field.");
+                        }
+                        break;
+
+                    case 'H':
+                        if (state.compareTo(State.HOUR) < 0) {
+                            hour = value;
+                            state = State.HOUR;
+                        } else {
+                            throw new HyracksDataException(durationErrorMessage + ": wrong HOUR field.");
+                        }
+                        break;
+                    case '.':
+                        if (state.compareTo(State.MILLISEC) < 0) {
+                            int i = 1;
+                            for (; offset + i < length; i++) {
+                                if (charAccessor[start + offset + i] >= '0' && charAccessor[start + offset + i] <= '9') {
+                                    if (i < 4) {
+                                        millisecond = millisecond * 10 + (charAccessor[start + offset + i] - '0');
+                                    } else {
+                                        throw new HyracksDataException(durationErrorMessage
+                                                + ": wrong MILLISECOND field.");
+                                    }
+                                } else {
+                                    break;
+                                }
+                            }
+                            offset += i;
+                            state = State.MILLISEC;
+                        } else {
+                            throw new HyracksDataException(durationErrorMessage + ": wrong MILLISECOND field.");
+                        }
+                    case 'S':
+                        if (state.compareTo(State.SEC) < 0) {
+                            second = value;
+                            state = State.SEC;
+                        } else {
+                            throw new HyracksDataException(durationErrorMessage + ": wrong SECOND field.");
+                        }
+                        break;
+                    default:
+                        throw new HyracksDataException(durationErrorMessage + ": wrong format for duration.");
+
+                }
+                value = 0;
+            }
+        }
+
+        if (state.compareTo(State.TIME) == 0) {
+            throw new HyracksDataException(durationErrorMessage + ": no time fields after time separator.");
+        }
+
+        short temp = 1;
+        if (!positive) {
+            temp = -1;
+        }
+
+        aDuration.setValue(temp * (year * 12 + month), temp
+                * (day * 24 * 3600 * 1000L + 3600 * 1000L * hour + 60 * minute * 1000L + second * 1000L + millisecond));
+
+    }
+
+    /**
+     * Copy-and-paste the code in {@link #parseDuration(String, int, int, AMutableDuration)} in order to eliminate
+     * object creation.
+     * 
+     * @param charAccessor
+     * @param start
+     * @param length
+     * @param aDuration
+     * @throws HyracksDataException
+     */
+    public static void parseDuration(byte[] charAccessor, int start, int length, AMutableDuration aDuration)
+            throws HyracksDataException {
+
+        boolean positive = true;
+        int offset = 0;
+        int value = 0, hour = 0, minute = 0, second = 0, millisecond = 0, year = 0, month = 0, day = 0;
+        State state = State.NOTHING_READ;
+
+        if (charAccessor[start + offset] == '-') {
+            offset++;
+            positive = false;
+        }
+
+        if (charAccessor[start + offset] != 'P') {
+            throw new HyracksDataException(durationErrorMessage + ": Missing leading 'P'.");
+        }
+
+        offset++;
+
+        for (; offset < length; offset++) {
+            if (charAccessor[start + offset] >= '0' && charAccessor[start + offset] <= '9') {
+                // accumulate the digit fields
+                value = value * 10 + charAccessor[start + offset] - '0';
+            } else {
+                switch (charAccessor[start + offset]) {
+                    case 'Y':
+                        if (state.compareTo(State.YEAR) < 0) {
+                            year = value;
+                            state = State.YEAR;
+                        } else {
+                            throw new HyracksDataException(durationErrorMessage + ": wrong YEAR feild.");
+                        }
+                        break;
+                    case 'M':
+                        if (state.compareTo(State.TIME) < 0) {
+                            if (state.compareTo(State.MONTH) < 0) {
+                                month = value;
+                                state = State.MONTH;
+                            } else {
+                                throw new HyracksDataException(durationErrorMessage + ": wrong MONTH field.");
+                            }
+                        } else if (state.compareTo(State.MIN) < 0) {
+                            minute = value;
+                            state = State.MIN;
+                        } else {
+                            throw new HyracksDataException(durationErrorMessage + ": wrong MIN field.");
+                        }
+                        break;
+                    case 'D':
+                        if (state.compareTo(State.DAY) < 0) {
+                            day = value;
+                            state = State.DAY;
+                        } else {
+                            throw new HyracksDataException(durationErrorMessage + ": wrong DAY field");
+                        }
+                        break;
+                    case 'T':
+                        if (state.compareTo(State.TIME) < 0) {
+                            state = State.TIME;
+                        } else {
+                            throw new HyracksDataException(durationErrorMessage + ": wrong TIME field.");
+                        }
+                        break;
+
+                    case 'H':
+                        if (state.compareTo(State.HOUR) < 0) {
+                            hour = value;
+                            state = State.HOUR;
+                        } else {
+                            throw new HyracksDataException(durationErrorMessage + ": wrong HOUR field.");
+                        }
+                        break;
+                    case '.':
+                        if (state.compareTo(State.MILLISEC) < 0) {
+                            int i = 1;
+                            for (; offset + i < length; i++) {
+                                if (charAccessor[start + offset + i] >= '0' && charAccessor[start + offset + i] <= '9') {
+                                    if (i < 4) {
+                                        millisecond = millisecond * 10 + (charAccessor[start + offset + i] - '0');
                                     } else {
                                         throw new HyracksDataException(durationErrorMessage
                                                 + ": wrong MILLISECOND field.");
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ATimeParserFactory.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ATimeParserFactory.java
index d76f41d..4c4e3fa 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ATimeParserFactory.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ATimeParserFactory.java
@@ -36,15 +36,12 @@
     @Override
     public IValueParser createValueParser() {
 
-        final CharArrayCharSequenceAccessor charArrayAccessor = new CharArrayCharSequenceAccessor();
-
         return new IValueParser() {
 
             @Override
             public void parse(char[] buffer, int start, int length, DataOutput out) throws HyracksDataException {
-                charArrayAccessor.reset(buffer, start, length);
                 try {
-                    out.writeInt(parseTimePart(charArrayAccessor));
+                    out.writeInt(parseTimePart(buffer, start, length));
                 } catch (IOException ex) {
                     throw new HyracksDataException(ex);
                 }
@@ -53,32 +50,34 @@
     }
 
     /**
-     * Parse the given char sequence as a time string, and return the milliseconds represented by the time.
+     * Parse the given string as a time string, and return the milliseconds represented by the time.
      * 
-     * @param charAccessor
+     * @param timeString
+     * @param start
+     * @param length
      * @return
-     * @throws Exception
+     * @throws HyracksDataException
      */
-    public static <T> int parseTimePart(ICharSequenceAccessor<T> charAccessor) throws HyracksDataException {
+    public static <T> int parseTimePart(String timeString, int start, int length) throws HyracksDataException {
 
-        int length = charAccessor.getLength();
         int offset = 0;
 
         int hour = 0, min = 0, sec = 0, millis = 0;
         int timezone = 0;
 
         boolean isExtendedForm = false;
-        if (charAccessor.getCharAt(offset + 2) == ':') {
+        if (timeString.charAt(start + offset + 2) == ':') {
             isExtendedForm = true;
         }
 
-        if (isExtendedForm && (charAccessor.getCharAt(offset + 2) != ':' || charAccessor.getCharAt(offset + 5) != ':')) {
+        if (isExtendedForm
+                && (timeString.charAt(start + offset + 2) != ':' || timeString.charAt(start + offset + 5) != ':')) {
             throw new HyracksDataException(timeErrorMessage + ": Missing colon in an extended time format.");
         }
         // hour
         for (int i = 0; i < 2; i++) {
-            if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
-                hour = hour * 10 + charAccessor.getCharAt(offset + i) - '0';
+            if ((timeString.charAt(start + offset + i) >= '0' && timeString.charAt(start + offset + i) <= '9')) {
+                hour = hour * 10 + timeString.charAt(start + offset + i) - '0';
             } else {
                 throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in hour field");
             }
@@ -93,8 +92,8 @@
 
         // minute
         for (int i = 0; i < 2; i++) {
-            if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
-                min = min * 10 + charAccessor.getCharAt(offset + i) - '0';
+            if ((timeString.charAt(start + offset + i) >= '0' && timeString.charAt(start + offset + i) <= '9')) {
+                min = min * 10 + timeString.charAt(start + offset + i) - '0';
             } else {
                 throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in minute field");
             }
@@ -109,8 +108,8 @@
 
         // second
         for (int i = 0; i < 2; i++) {
-            if ((charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9')) {
-                sec = sec * 10 + charAccessor.getCharAt(offset + i) - '0';
+            if ((timeString.charAt(start + offset + i) >= '0' && timeString.charAt(start + offset + i) <= '9')) {
+                sec = sec * 10 + timeString.charAt(start + offset + i) - '0';
             } else {
                 throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in second field");
             }
@@ -123,14 +122,14 @@
 
         offset += 2;
 
-        if ((isExtendedForm && length > offset && charAccessor.getCharAt(offset) == '.')
+        if ((isExtendedForm && length > offset && timeString.charAt(start + offset) == '.')
                 || (!isExtendedForm && length > offset)) {
 
             offset += (isExtendedForm) ? 1 : 0;
             int i = 0;
             for (; i < 3 && offset + i < length; i++) {
-                if (charAccessor.getCharAt(offset + i) >= '0' && charAccessor.getCharAt(offset + i) <= '9') {
-                    millis = millis * 10 + charAccessor.getCharAt(offset + i) - '0';
+                if (timeString.charAt(start + offset + i) >= '0' && timeString.charAt(start + offset + i) <= '9') {
+                    millis = millis * 10 + timeString.charAt(start + offset + i) - '0';
                 } else {
                     break;
                 }
@@ -143,32 +142,31 @@
             }
 
             // error is thrown if more than three digits are seen for the millisecond part
-            if (charAccessor.getLength() > offset && charAccessor.getCharAt(offset) >= '0'
-                    && charAccessor.getCharAt(offset) <= '9') {
+            if (length > offset && timeString.charAt(start + offset) >= '0' && timeString.charAt(start + offset) <= '9') {
                 throw new HyracksDataException(timeErrorMessage + ": too many fields for millisecond.");
             }
         }
 
         if (length > offset) {
-            timezone = parseTimezonePart(charAccessor, offset);
+            timezone = parseTimezonePart(timeString, start + offset);
         }
 
         return GregorianCalendarSystem.getInstance().getChronon(hour, min, sec, millis, timezone);
     }
 
     /**
-     * Parse the given char sequence as a time string, and return the milliseconds represented by the time.
+     * Parse the given string as a time string, and parse the timezone field.
      * 
-     * @param charAccessor
+     * @param timeString
+     * @param start
      * @return
-     * @throws Exception
+     * @throws HyracksDataException
      */
-    public static <T> int parseTimezonePart(ICharSequenceAccessor<T> charAccessor, int offset)
-            throws HyracksDataException {
+    public static <T> int parseTimezonePart(String timeString, int start) throws HyracksDataException {
         int timezone = 0;
 
-        if (charAccessor.getCharAt(offset) != 'Z') {
-            if ((charAccessor.getCharAt(offset) != '+' && charAccessor.getCharAt(offset) != '-')) {
+        if (timeString.charAt(start) != 'Z') {
+            if ((timeString.charAt(start) != '+' && timeString.charAt(start) != '-')) {
                 throw new HyracksDataException("Wrong timezone format: missing sign or missing colon for a time zone");
             }
 
@@ -176,8 +174,8 @@
             short timezoneMinute = 0;
 
             for (int i = 0; i < 2; i++) {
-                if ((charAccessor.getCharAt(offset + 1 + i) >= '0' && charAccessor.getCharAt(offset + 1 + i) <= '9')) {
-                    timezoneHour = (short) (timezoneHour * 10 + charAccessor.getCharAt(offset + 1 + i) - '0');
+                if ((timeString.charAt(start + 1 + i) >= '0' && timeString.charAt(start + 1 + i) <= '9')) {
+                    timezoneHour = (short) (timezoneHour * 10 + timeString.charAt(start + 1 + i) - '0');
                 } else {
                     throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone hour field");
                 }
@@ -188,13 +186,12 @@
                 throw new HyracksDataException(timeErrorMessage + ": time zone hour " + timezoneHour);
             }
 
-            int temp_offset = (charAccessor.getCharAt(offset + 3) == ':') ? 1 : 0;
+            int temp_offset = (timeString.charAt(start + 3) == ':') ? 1 : 0;
 
             for (int i = 0; i < 2; i++) {
-                if ((charAccessor.getCharAt(offset + temp_offset + 3 + i) >= '0' && charAccessor.getCharAt(offset
-                        + temp_offset + 3 + i) <= '9')) {
-                    timezoneMinute = (short) (timezoneMinute * 10
-                            + charAccessor.getCharAt(offset + temp_offset + 3 + i) - '0');
+                if ((timeString.charAt(start + temp_offset + 3 + i) >= '0' && timeString.charAt(start + temp_offset + 3
+                        + i) <= '9')) {
+                    timezoneMinute = (short) (timezoneMinute * 10 + timeString.charAt(start + temp_offset + 3 + i) - '0');
                 } else {
                     throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone minute field");
                 }
@@ -205,7 +202,333 @@
                 throw new HyracksDataException(timeErrorMessage + ": time zone minute " + timezoneMinute);
             }
 
-            if (charAccessor.getCharAt(offset) == '-') {
+            if (timeString.charAt(start) == '-') {
+                timezone = (byte) -((timezoneHour * 4) + timezoneMinute / 15);
+            } else {
+                timezone = (byte) ((timezoneHour * 4) + timezoneMinute / 15);
+            }
+        }
+        return timezone;
+    }
+
+    /**
+     * Similar to {@link #parseTimePart(String, int, int)} but use a char array as input; although this is almost
+     * a copy-and-past code but it avoids object creation.
+     * 
+     * @param timeString
+     * @param start
+     * @param length
+     * @return
+     * @throws HyracksDataException
+     */
+    public static int parseTimePart(char[] timeString, int start, int length) throws HyracksDataException {
+
+        int offset = 0;
+
+        int hour = 0, min = 0, sec = 0, millis = 0;
+        int timezone = 0;
+
+        boolean isExtendedForm = false;
+        if (timeString[start + offset + 2] == ':') {
+            isExtendedForm = true;
+        }
+
+        if (isExtendedForm && (timeString[start + offset + 2] != ':' || timeString[start + offset + 5] != ':')) {
+            throw new HyracksDataException(timeErrorMessage + ": Missing colon in an extended time format.");
+        }
+        // hour
+        for (int i = 0; i < 2; i++) {
+            if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+                hour = hour * 10 + timeString[start + offset + i] - '0';
+            } else {
+                throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in hour field");
+            }
+        }
+
+        if (hour < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.HOUR.ordinal()]
+                || hour > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.HOUR.ordinal()]) {
+            throw new HyracksDataException(timeErrorMessage + ": hour " + hour);
+        }
+
+        offset += (isExtendedForm) ? 3 : 2;
+
+        // minute
+        for (int i = 0; i < 2; i++) {
+            if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+                min = min * 10 + timeString[start + offset + i] - '0';
+            } else {
+                throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in minute field");
+            }
+        }
+
+        if (min < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.MINUTE.ordinal()]
+                || min > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.MINUTE.ordinal()]) {
+            throw new HyracksDataException(timeErrorMessage + ": min " + min);
+        }
+
+        offset += (isExtendedForm) ? 3 : 2;
+
+        // second
+        for (int i = 0; i < 2; i++) {
+            if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+                sec = sec * 10 + timeString[start + offset + i] - '0';
+            } else {
+                throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in second field");
+            }
+        }
+
+        if (sec < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.SECOND.ordinal()]
+                || sec > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.SECOND.ordinal()]) {
+            throw new HyracksDataException(timeErrorMessage + ": sec " + sec);
+        }
+
+        offset += 2;
+
+        if ((isExtendedForm && length > offset && timeString[start + offset] == '.')
+                || (!isExtendedForm && length > offset)) {
+
+            offset += (isExtendedForm) ? 1 : 0;
+            int i = 0;
+            for (; i < 3 && offset + i < length; i++) {
+                if (timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9') {
+                    millis = millis * 10 + timeString[start + offset + i] - '0';
+                } else {
+                    break;
+                }
+            }
+
+            offset += i;
+
+            for (; i < 3; i++) {
+                millis = millis * 10;
+            }
+
+            // error is thrown if more than three digits are seen for the millisecond part
+            if (length > offset && timeString[start + offset] >= '0' && timeString[start + offset] <= '9') {
+                throw new HyracksDataException(timeErrorMessage + ": too many fields for millisecond.");
+            }
+        }
+
+        if (length > offset) {
+            timezone = parseTimezonePart(timeString, start + offset);
+        }
+
+        return GregorianCalendarSystem.getInstance().getChronon(hour, min, sec, millis, timezone);
+    }
+
+    /**
+     * Similar to {@link #parseTimezonePart(String, int)} but use a char array as input; although this is almost
+     * a copy-and-past code but it avoids object creation.
+     * 
+     * @param timeString
+     * @param start
+     * @param length
+     * @return
+     * @throws HyracksDataException
+     */
+    public static int parseTimezonePart(char[] timeString, int start) throws HyracksDataException {
+        int timezone = 0;
+
+        if (timeString[start] != 'Z') {
+            if ((timeString[start] != '+' && timeString[start] != '-')) {
+                throw new HyracksDataException("Wrong timezone format: missing sign or missing colon for a time zone");
+            }
+
+            short timezoneHour = 0;
+            short timezoneMinute = 0;
+
+            for (int i = 0; i < 2; i++) {
+                if ((timeString[start + 1 + i] >= '0' && timeString[start + 1 + i] <= '9')) {
+                    timezoneHour = (short) (timezoneHour * 10 + timeString[start + 1 + i] - '0');
+                } else {
+                    throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone hour field");
+                }
+            }
+
+            if (timezoneHour < GregorianCalendarSystem.TIMEZONE_HOUR_MIN
+                    || timezoneHour > GregorianCalendarSystem.TIMEZONE_HOUR_MAX) {
+                throw new HyracksDataException(timeErrorMessage + ": time zone hour " + timezoneHour);
+            }
+
+            int temp_offset = (timeString[start + 3] == ':') ? 1 : 0;
+
+            for (int i = 0; i < 2; i++) {
+                if ((timeString[start + temp_offset + 3 + i] >= '0' && timeString[start + temp_offset + 3 + i] <= '9')) {
+                    timezoneMinute = (short) (timezoneMinute * 10 + timeString[start + temp_offset + 3 + i] - '0');
+                } else {
+                    throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone minute field");
+                }
+            }
+
+            if (timezoneMinute < GregorianCalendarSystem.TIMEZONE_MIN_MIN
+                    || timezoneMinute > GregorianCalendarSystem.TIMEZONE_MIN_MAX) {
+                throw new HyracksDataException(timeErrorMessage + ": time zone minute " + timezoneMinute);
+            }
+
+            if (timeString[start] == '-') {
+                timezone = (byte) -((timezoneHour * 4) + timezoneMinute / 15);
+            } else {
+                timezone = (byte) ((timezoneHour * 4) + timezoneMinute / 15);
+            }
+        }
+        return timezone;
+    }
+
+    /**
+     * Similar to {@link #parseTimePart(String, int, int)} but use a byte array as input; although this is almost
+     * a copy-and-past code but it avoids object creation.
+     * 
+     * @param timeString
+     * @param start
+     * @param length
+     * @return
+     * @throws HyracksDataException
+     */
+    public static int parseTimePart(byte[] timeString, int start, int length) throws HyracksDataException {
+
+        int offset = 0;
+
+        int hour = 0, min = 0, sec = 0, millis = 0;
+        int timezone = 0;
+
+        boolean isExtendedForm = false;
+        if (timeString[start + offset + 2] == ':') {
+            isExtendedForm = true;
+        }
+
+        if (isExtendedForm && (timeString[start + offset + 2] != ':' || timeString[start + offset + 5] != ':')) {
+            throw new HyracksDataException(timeErrorMessage + ": Missing colon in an extended time format.");
+        }
+        // hour
+        for (int i = 0; i < 2; i++) {
+            if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+                hour = hour * 10 + timeString[start + offset + i] - '0';
+            } else {
+                throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in hour field");
+            }
+        }
+
+        if (hour < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.HOUR.ordinal()]
+                || hour > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.HOUR.ordinal()]) {
+            throw new HyracksDataException(timeErrorMessage + ": hour " + hour);
+        }
+
+        offset += (isExtendedForm) ? 3 : 2;
+
+        // minute
+        for (int i = 0; i < 2; i++) {
+            if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+                min = min * 10 + timeString[start + offset + i] - '0';
+            } else {
+                throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in minute field");
+            }
+        }
+
+        if (min < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.MINUTE.ordinal()]
+                || min > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.MINUTE.ordinal()]) {
+            throw new HyracksDataException(timeErrorMessage + ": min " + min);
+        }
+
+        offset += (isExtendedForm) ? 3 : 2;
+
+        // second
+        for (int i = 0; i < 2; i++) {
+            if ((timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9')) {
+                sec = sec * 10 + timeString[start + offset + i] - '0';
+            } else {
+                throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in second field");
+            }
+        }
+
+        if (sec < GregorianCalendarSystem.FIELD_MINS[GregorianCalendarSystem.Fields.SECOND.ordinal()]
+                || sec > GregorianCalendarSystem.FIELD_MAXS[GregorianCalendarSystem.Fields.SECOND.ordinal()]) {
+            throw new HyracksDataException(timeErrorMessage + ": sec " + sec);
+        }
+
+        offset += 2;
+
+        if ((isExtendedForm && length > offset && timeString[start + offset] == '.')
+                || (!isExtendedForm && length > offset)) {
+
+            offset += (isExtendedForm) ? 1 : 0;
+            int i = 0;
+            for (; i < 3 && offset + i < length; i++) {
+                if (timeString[start + offset + i] >= '0' && timeString[start + offset + i] <= '9') {
+                    millis = millis * 10 + timeString[start + offset + i] - '0';
+                } else {
+                    break;
+                }
+            }
+
+            offset += i;
+
+            for (; i < 3; i++) {
+                millis = millis * 10;
+            }
+
+            // error is thrown if more than three digits are seen for the millisecond part
+            if (length > offset && timeString[start + offset] >= '0' && timeString[start + offset] <= '9') {
+                throw new HyracksDataException(timeErrorMessage + ": too many fields for millisecond.");
+            }
+        }
+
+        if (length > offset) {
+            timezone = parseTimezonePart(timeString, start + offset);
+        }
+
+        return GregorianCalendarSystem.getInstance().getChronon(hour, min, sec, millis, timezone);
+    }
+
+    /**
+     * Similar to {@link #parseTimezonePart(String, int)} but use a byte array as input; although this is almost
+     * a copy-and-past code but it avoids object creation.
+     * 
+     * @param timeString
+     * @param start
+     * @param length
+     * @return
+     * @throws HyracksDataException
+     */
+    public static int parseTimezonePart(byte[] timeString, int start) throws HyracksDataException {
+        int timezone = 0;
+
+        if (timeString[start] != 'Z') {
+            if ((timeString[start] != '+' && timeString[start] != '-')) {
+                throw new HyracksDataException("Wrong timezone format: missing sign or missing colon for a time zone");
+            }
+
+            short timezoneHour = 0;
+            short timezoneMinute = 0;
+
+            for (int i = 0; i < 2; i++) {
+                if ((timeString[start + 1 + i] >= '0' && timeString[start + 1 + i] <= '9')) {
+                    timezoneHour = (short) (timezoneHour * 10 + timeString[start + 1 + i] - '0');
+                } else {
+                    throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone hour field");
+                }
+            }
+
+            if (timezoneHour < GregorianCalendarSystem.TIMEZONE_HOUR_MIN
+                    || timezoneHour > GregorianCalendarSystem.TIMEZONE_HOUR_MAX) {
+                throw new HyracksDataException(timeErrorMessage + ": time zone hour " + timezoneHour);
+            }
+
+            int temp_offset = (timeString[start + 3] == ':') ? 1 : 0;
+
+            for (int i = 0; i < 2; i++) {
+                if ((timeString[start + temp_offset + 3 + i] >= '0' && timeString[start + temp_offset + 3 + i] <= '9')) {
+                    timezoneMinute = (short) (timezoneMinute * 10 + timeString[start + temp_offset + 3 + i] - '0');
+                } else {
+                    throw new HyracksDataException(timeErrorMessage + ": Non-numeric value in timezone minute field");
+                }
+            }
+
+            if (timezoneMinute < GregorianCalendarSystem.TIMEZONE_MIN_MIN
+                    || timezoneMinute > GregorianCalendarSystem.TIMEZONE_MIN_MAX) {
+                throw new HyracksDataException(timeErrorMessage + ": time zone minute " + timezoneMinute);
+            }
+
+            if (timeString[start] == '-') {
                 timezone = (byte) -((timezoneHour * 4) + timezoneMinute / 15);
             } else {
                 timezone = (byte) ((timezoneHour * 4) + timezoneMinute / 15);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ByteArrayCharSequenceAccessor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ByteArrayCharSequenceAccessor.java
deleted file mode 100644
index 453c86f..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ByteArrayCharSequenceAccessor.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2009-2011 by The Regents of the University of California
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * you may obtain a copy of the License from
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package edu.uci.ics.asterix.om.base.temporal;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixRuntimeException;
-
-public class ByteArrayCharSequenceAccessor implements ICharSequenceAccessor<Byte[]> {
-
-    private byte[] buf;
-    private int offset;
-    private int length;
-
-    @Override
-    public char getCharAt(int index) throws AsterixRuntimeException {
-        if (index < 0 || index >= length) {
-            throw new AsterixRuntimeException("Byte array char accessor is out of bound: " + index + ":" + length);
-        }
-        return (char) (buf[index + offset]);
-    }
-
-    /**
-     * Reset the wrapped byte array.
-     * 
-     * @param obj
-     *            The byte array to be wrapped
-     * @param beginOffset
-     *            The offset of the string stored in the byte array.
-     * @param offset
-     *            The offset of the substring of the string stored (offset from the beginOffset).
-     */
-    public void reset(byte[] obj, int offset, int length) {
-        this.buf = obj;
-        this.offset = offset;
-        this.length = length;
-    }
-
-    @Override
-    public int getLength() {
-        return length;
-    }
-
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/CharArrayCharSequenceAccessor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/CharArrayCharSequenceAccessor.java
deleted file mode 100644
index 404f0ee..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/CharArrayCharSequenceAccessor.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2009-2011 by The Regents of the University of California
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * you may obtain a copy of the License from
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package edu.uci.ics.asterix.om.base.temporal;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixRuntimeException;
-
-public class CharArrayCharSequenceAccessor implements ICharSequenceAccessor<char[]> {
-
-    private char[] buf;
-    private int offset;
-    private int length;
-    
-    @Override
-    public char getCharAt(int index) throws AsterixRuntimeException {
-        if (index < 0 || index >= length) {
-            throw new AsterixRuntimeException("Byte array char accessor is out of bound: " + index + ":" + length);
-        }
-        return (char) (buf[index + offset]);
-    }
-
-    /**
-     * Reset the wrapped byte array.
-     * 
-     * @param obj
-     *            The byte array to be wrapped
-     * @param beginOffset
-     *            The offset of the string stored in the byte array.
-     * @param offset
-     *            The offset of the substring of the string stored (offset from the beginOffset).
-     */
-    public void reset(char[] obj, int offset, int length) {
-        this.buf = obj;
-        this.offset = offset;
-        this.length = length;
-    }
-
-    @Override
-    public int getLength() {
-        return length;
- }
-
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ICharSequenceAccessor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ICharSequenceAccessor.java
deleted file mode 100644
index d5a99a0..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/ICharSequenceAccessor.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2009-2011 by The Regents of the University of California
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * you may obtain a copy of the License from
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package edu.uci.ics.asterix.om.base.temporal;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixRuntimeException;
-
-public interface ICharSequenceAccessor<T> {
-
-    /**
-     * Return the character in the wrapped char sequence at the given index.
-     * 
-     * @param index
-     * @return
-     */
-    public char getCharAt(int index) throws AsterixRuntimeException;
-
-    /**
-     * Get the length of the wrapped char sequence.
-     * 
-     * @return
-     */
-    public int getLength();
-
-}
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/StringCharSequenceAccessor.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/StringCharSequenceAccessor.java
deleted file mode 100644
index 17e483a..0000000
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/base/temporal/StringCharSequenceAccessor.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2009-2011 by The Regents of the University of California
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * you may obtain a copy of the License from
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package edu.uci.ics.asterix.om.base.temporal;
-
-import edu.uci.ics.asterix.common.exceptions.AsterixRuntimeException;
-
-public class StringCharSequenceAccessor implements ICharSequenceAccessor<String> {
-
-    private String string;
-    private int offset;
-    private int length;
-
-    @Override
-    public char getCharAt(int index) throws AsterixRuntimeException {
-        if (index >= length) {
-            throw new AsterixRuntimeException("String accessor is out of bound.");
-        }
-        return string.charAt(index + offset);
-    }
-
-    public void reset(String obj, int offset, int len) {
-        this.string = obj;
-        this.offset = offset;
-        this.length = len;
-    }
-
-    @Override
-    public int getLength() {
-        return length;
-    }
-
-}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
index d5d703d..a1f9911 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
@@ -22,7 +22,6 @@
 import edu.uci.ics.asterix.om.base.AMutableDate;
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
 import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -73,8 +72,6 @@
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
-                    private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
 
@@ -95,8 +92,8 @@
                                     endOffset--;
                                 }
 
-                                charAccessor.reset(serString, startOffset, endOffset - startOffset + 1);
-                                long chrononTimeInMs = ADateParserFactory.parseDatePart(charAccessor);
+                                long chrononTimeInMs = ADateParserFactory.parseDatePart(serString, startOffset,
+                                        endOffset - startOffset + 1);
 
                                 short temp = 0;
                                 if (chrononTimeInMs < 0
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
index f1565aa..83f4c8b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
@@ -23,7 +23,6 @@
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
 import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -72,7 +71,6 @@
                     @SuppressWarnings("unchecked")
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
-                    private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
 
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
@@ -85,27 +83,22 @@
 
                                 int stringLength = (serString[1] & 0xff << 8) + (serString[2] & 0xff << 0);
 
-                                charAccessor.reset(serString, 3, stringLength);
-
                                 // +1 if it is negative (-)
-                                short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+                                short timeOffset = (short) ((serString[3] == '-') ? 1 : 0);
 
                                 timeOffset += 8;
 
-                                if (charAccessor.getCharAt(timeOffset) != 'T') {
+                                if (serString[3 + timeOffset] != 'T') {
                                     timeOffset += 2;
-                                    if (charAccessor.getCharAt(timeOffset) != 'T') {
+                                    if (serString[3 + timeOffset] != 'T') {
                                         throw new AlgebricksException(errorMessage + ": missing T");
                                     }
                                 }
 
-                                charAccessor.reset(serString, 3, timeOffset);
+                                long chrononTimeInMs = ADateParserFactory.parseDatePart(serString, 3, timeOffset);
 
-                                long chrononTimeInMs = ADateParserFactory.parseDatePart(charAccessor);
-
-                                charAccessor.reset(serString, 3 + timeOffset + 1, stringLength - timeOffset - 1);
-
-                                chrononTimeInMs += ATimeParserFactory.parseTimePart(charAccessor);
+                                chrononTimeInMs += ATimeParserFactory.parseTimePart(serString, 3 + timeOffset + 1,
+                                        stringLength - timeOffset - 1);
 
                                 aDateTime.setValue(chrononTimeInMs);
                                 datetimeSerde.serialize(aDateTime, out);
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
index b2b3f4e..a84ae1d 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
@@ -21,7 +21,6 @@
 import edu.uci.ics.asterix.om.base.AMutableDuration;
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
 import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -43,8 +42,6 @@
     private final static byte SER_STRING_TYPE_TAG = ATypeTag.STRING.serialize();
     private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
 
-    private final static ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
     public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
         public IFunctionDescriptor createFunctionDescriptor() {
             return new ADurationConstructorDescriptor();
@@ -85,9 +82,7 @@
 
                                 int stringLength = (serString[1] & 0xff << 8) + (serString[2] & 0xff << 0);
 
-                                charAccessor.reset(serString, 3, stringLength);
-
-                                ADurationParserFactory.parseDuration(charAccessor, aDuration);
+                                ADurationParserFactory.parseDuration(serString, 3, stringLength, aDuration);
 
                                 durationSerde.serialize(aDuration, out);
                             } else if (serString[0] == SER_NULL_TYPE_TAG) {
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
index 3ac64f3..0414874 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateConstructorDescriptor.java
@@ -23,7 +23,6 @@
 import edu.uci.ics.asterix.om.base.AMutableInterval;
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -78,8 +77,6 @@
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
-                    private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
 
@@ -100,17 +97,15 @@
                                         + (argOut0.getByteArray()[2] & 0xff << 0);
 
                                 // start date
-                                charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
-                                long intervalStart = ADateParserFactory.parseDatePart(charAccessor)
-                                        / GregorianCalendarSystem.CHRONON_OF_DAY;
+                                long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
+                                        stringLength) / GregorianCalendarSystem.CHRONON_OF_DAY;
 
                                 // end date
                                 stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
                                         + (argOut1.getByteArray()[2] & 0xff << 0);
 
-                                charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
-                                long intervalEnd = ADateParserFactory.parseDatePart(charAccessor)
-                                        / GregorianCalendarSystem.CHRONON_OF_DAY;
+                                long intervalEnd = ADateParserFactory.parseDatePart(argOut1.getByteArray(), 3,
+                                        stringLength) / GregorianCalendarSystem.CHRONON_OF_DAY;
 
                                 if (intervalEnd < intervalStart) {
                                     throw new AlgebricksException(
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
index 35d1a02..6b3e2b6 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromDateTimeConstructorDescriptor.java
@@ -24,7 +24,6 @@
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
 import edu.uci.ics.asterix.om.types.ATypeTag;
@@ -78,8 +77,6 @@
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
-                    private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
 
@@ -99,43 +96,39 @@
                                 int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
                                         + (argOut0.getByteArray()[2] & 0xff << 0);
 
-                                charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
                                 // get offset for time part: +1 if it is negative (-)
-                                short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+                                short timeOffset = (short) ((argOut0.getByteArray()[3] == '-') ? 1 : 0);
                                 timeOffset += 8;
-                                if (charAccessor.getCharAt(timeOffset) != 'T') {
+                                if (argOut0.getByteArray()[3 + timeOffset] != 'T') {
                                     timeOffset += 2;
-                                    if (charAccessor.getCharAt(timeOffset) != 'T') {
+                                    if (argOut0.getByteArray()[3 + timeOffset] != 'T') {
                                         throw new AlgebricksException(errorMessage + ": missing T");
                                     }
                                 }
 
-                                charAccessor.reset(argOut0.getByteArray(), 3, timeOffset);
-                                long intervalStart = ADateParserFactory.parseDatePart(charAccessor);
-                                charAccessor.reset(argOut0.getByteArray(), 3 + timeOffset + 1, stringLength
-                                        - timeOffset - 1);
-                                intervalStart += ATimeParserFactory.parseTimePart(charAccessor);
+                                long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
+                                        timeOffset);
+                                intervalStart += ATimeParserFactory.parseTimePart(argOut0.getByteArray(),
+                                        3 + timeOffset + 1, stringLength - timeOffset - 1);
 
                                 // end datetime
                                 stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
                                         + (argOut1.getByteArray()[2] & 0xff << 0);
 
-                                charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
                                 // get offset for time part: +1 if it is negative (-)
-                                timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+                                timeOffset = (short) ((argOut1.getByteArray()[3] == '-') ? 1 : 0);
                                 timeOffset += 8;
-                                if (charAccessor.getCharAt(timeOffset) != 'T') {
+                                if (argOut1.getByteArray()[3 + timeOffset] != 'T') {
                                     timeOffset += 2;
-                                    if (charAccessor.getCharAt(timeOffset) != 'T') {
+                                    if (argOut1.getByteArray()[3 + timeOffset] != 'T') {
                                         throw new AlgebricksException(errorMessage + ": missing T");
                                     }
                                 }
 
-                                charAccessor.reset(argOut1.getByteArray(), 3, timeOffset);
-                                long intervalEnd = ADateParserFactory.parseDatePart(charAccessor);
-                                charAccessor.reset(argOut1.getByteArray(), 3 + timeOffset + 1, stringLength
-                                        - timeOffset - 1);
-                                intervalEnd += ATimeParserFactory.parseTimePart(charAccessor);
+                                long intervalEnd = ADateParserFactory.parseDatePart(argOut1.getByteArray(), 3,
+                                        timeOffset);
+                                intervalEnd += ATimeParserFactory.parseTimePart(argOut1.getByteArray(),
+                                        3 + timeOffset + 1, stringLength - timeOffset - 1);
 
                                 if (intervalEnd < intervalStart) {
                                     throw new AlgebricksException(
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
index 73080c8..042a33b 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalFromTimeConstructorDescriptor.java
@@ -23,7 +23,6 @@
 import edu.uci.ics.asterix.om.base.AMutableInterval;
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -78,8 +77,6 @@
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
-                    private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
 
@@ -99,8 +96,8 @@
                                 int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
                                         + (argOut0.getByteArray()[2] & 0xff << 0);
 
-                                charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
-                                long intervalStart = ATimeParserFactory.parseTimePart(charAccessor);
+                                long intervalStart = ATimeParserFactory.parseTimePart(argOut0.getByteArray(), 3,
+                                        stringLength);
                                 if (intervalStart < 0) {
                                     intervalStart += GregorianCalendarSystem.CHRONON_OF_DAY;
                                 }
@@ -109,8 +106,8 @@
                                 stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
                                         + (argOut1.getByteArray()[2] & 0xff << 0);
 
-                                charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
-                                long intervalEnd = ATimeParserFactory.parseTimePart(charAccessor);
+                                long intervalEnd = ATimeParserFactory.parseTimePart(argOut1.getByteArray(), 3,
+                                        stringLength);
                                 if (intervalEnd < 0) {
                                     intervalEnd += GregorianCalendarSystem.CHRONON_OF_DAY;
                                 }
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
index 6429daa..d5a0db9 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
@@ -25,7 +25,6 @@
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
 import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -82,8 +81,6 @@
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
-                    private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
 
@@ -104,15 +101,15 @@
                                 int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
                                         + (argOut0.getByteArray()[2] & 0xff << 0);
 
-                                charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
-                                long intervalStart = ADateParserFactory.parseDatePart(charAccessor);
+                                long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
+                                        stringLength);
 
                                 // duration
                                 stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
                                         + (argOut1.getByteArray()[2] & 0xff << 0);
 
-                                charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
-                                ADurationParserFactory.parseDuration(charAccessor, aDuration);
+                                ADurationParserFactory
+                                        .parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
 
                                 long intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
                                         aDuration.getMonths(), aDuration.getMilliseconds());
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
index 7366f1c..d821fc3 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
@@ -26,7 +26,6 @@
 import edu.uci.ics.asterix.om.base.temporal.ADateParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
 import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
@@ -82,8 +81,6 @@
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
-                    private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
 
@@ -104,31 +101,29 @@
                                 int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
                                         + (argOut0.getByteArray()[2] & 0xff << 0);
 
-                                charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
                                 // get offset for time part: +1 if it is negative (-)
-                                short timeOffset = (short) ((charAccessor.getCharAt(0) == '-') ? 1 : 0);
+                                short timeOffset = (short) ((argOut0.getByteArray()[3] == '-') ? 1 : 0);
 
                                 timeOffset += 8;
 
-                                if (charAccessor.getCharAt(timeOffset) != 'T') {
+                                if (argOut0.getByteArray()[3 + timeOffset] != 'T') {
                                     timeOffset += 2;
-                                    if (charAccessor.getCharAt(timeOffset) != 'T') {
+                                    if (argOut0.getByteArray()[3 + timeOffset] != 'T') {
                                         throw new AlgebricksException(errorMessage + ": missing T");
                                     }
                                 }
 
-                                charAccessor.reset(argOut0.getByteArray(), 3, timeOffset);
-                                long intervalStart = ADateParserFactory.parseDatePart(charAccessor);
-                                charAccessor.reset(argOut0.getByteArray(), 3 + timeOffset + 1, stringLength
-                                        - timeOffset - 1);
-                                intervalStart += ATimeParserFactory.parseTimePart(charAccessor);
+                                long intervalStart = ADateParserFactory.parseDatePart(argOut0.getByteArray(), 3,
+                                        timeOffset);
+                                intervalStart += ATimeParserFactory.parseTimePart(argOut0.getByteArray(),
+                                        3 + timeOffset + 1, stringLength - timeOffset - 1);
 
                                 // duration
                                 stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
                                         + (argOut1.getByteArray()[2] & 0xff << 0);
 
-                                charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
-                                ADurationParserFactory.parseDuration(charAccessor, aDuration);
+                                ADurationParserFactory
+                                        .parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
 
                                 long intervalEnd = DurationArithmeticOperations.addDuration(intervalStart,
                                         aDuration.getMonths(), aDuration.getMilliseconds());
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
index e576fef..8135598 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
@@ -25,7 +25,6 @@
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ADurationParserFactory;
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
 import edu.uci.ics.asterix.om.base.temporal.DurationArithmeticOperations;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -82,8 +81,6 @@
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
-                    private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
 
@@ -104,8 +101,8 @@
                                 int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
                                         + (argOut0.getByteArray()[2] & 0xff << 0);
 
-                                charAccessor.reset(argOut0.getByteArray(), 3, stringLength);
-                                int intervalStart = ATimeParserFactory.parseTimePart(charAccessor);
+                                int intervalStart = ATimeParserFactory.parseTimePart(argOut0.getByteArray(), 3,
+                                        stringLength);
 
                                 if (intervalStart < 0) {
                                     intervalStart += GregorianCalendarSystem.CHRONON_OF_DAY;
@@ -116,8 +113,8 @@
                                 stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
                                         + (argOut1.getByteArray()[2] & 0xff << 0);
 
-                                charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
-                                ADurationParserFactory.parseDuration(charAccessor, aDuration);
+                                ADurationParserFactory
+                                        .parseDuration(argOut1.getByteArray(), 3, stringLength, aDuration);
 
                                 if (aDuration.getMonths() != 0) {
                                     throw new AlgebricksException("Cannot add a year-month duration to a time value.");
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
index caff78b..f2ad400 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
@@ -22,7 +22,6 @@
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.ATime;
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
 import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -73,8 +72,6 @@
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
-                    private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
                     @Override
                     public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
 
@@ -86,8 +83,7 @@
 
                                 int stringLength = (serString[1] & 0xff << 8) + (serString[2] & 0xff << 0);
 
-                                charAccessor.reset(serString, 3, stringLength);
-                                int chrononTimeInMs = ATimeParserFactory.parseTimePart(charAccessor);
+                                int chrononTimeInMs = ATimeParserFactory.parseTimePart(serString, 3, stringLength);
 
                                 if (chrononTimeInMs < 0) {
                                     chrononTimeInMs += GregorianCalendarSystem.CHRONON_OF_DAY;
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
index fb01e97..275bf47 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
@@ -21,7 +21,6 @@
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem.Fields;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -81,8 +80,6 @@
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
-                    private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
                     private GregorianCalendarSystem calInstance = GregorianCalendarSystem.getInstance();
 
                     @Override
@@ -114,9 +111,7 @@
                             int stringLength = (argOut1.getByteArray()[1] & 0xff << 8)
                                     + (argOut1.getByteArray()[2] & 0xff << 0);
 
-                            charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
-
-                            int timezone = ATimeParserFactory.parseTimezonePart(charAccessor, 0);
+                            int timezone = ATimeParserFactory.parseTimezonePart(argOut1.getByteArray(), 3);
 
                             if (!calInstance.validateTimeZone(timezone)) {
                                 throw new AlgebricksException("Wrong format for a time zone string!");
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
index 1323664..3f40c5c 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
@@ -21,7 +21,6 @@
 import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import edu.uci.ics.asterix.om.base.ANull;
 import edu.uci.ics.asterix.om.base.temporal.ATimeParserFactory;
-import edu.uci.ics.asterix.om.base.temporal.ByteArrayCharSequenceAccessor;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem;
 import edu.uci.ics.asterix.om.base.temporal.GregorianCalendarSystem.Fields;
 import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
@@ -81,8 +80,6 @@
                     private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
                             .getSerializerDeserializer(BuiltinType.ANULL);
 
-                    private ByteArrayCharSequenceAccessor charAccessor = new ByteArrayCharSequenceAccessor();
-
                     private GregorianCalendarSystem calInstance = GregorianCalendarSystem.getInstance();
 
                     @Override
@@ -114,9 +111,7 @@
                             int stringLength = (argOut0.getByteArray()[1] & 0xff << 8)
                                     + (argOut0.getByteArray()[2] & 0xff << 0);
 
-                            charAccessor.reset(argOut1.getByteArray(), 3, stringLength);
-
-                            int timezone = ATimeParserFactory.parseTimezonePart(charAccessor, 0);
+                            int timezone = ATimeParserFactory.parseTimezonePart(argOut1.getByteArray(), 3);
 
                             if (!calInstance.validateTimeZone(timezone)) {
                                 throw new AlgebricksException("Wrong format for a time zone string!");
