Merge "Remove DateException and obsolete DateUtils functions."

This commit is contained in:
Ken Shirriff
2010-03-01 22:46:07 -08:00
committed by Android (Google) Code Review
3 changed files with 0 additions and 132 deletions

View File

@@ -10,7 +10,6 @@ LOCAL_SRC_FILES := \
../core/java/android/pim/ICalendar.java \
../core/java/android/pim/RecurrenceSet.java \
../core/java/android/pim/ContactsAsyncHelper.java \
../core/java/android/pim/DateException.java
include $(BUILD_STATIC_JAVA_LIBRARY)

View File

@@ -1,26 +0,0 @@
/*
* Copyright (C) 2006 The Android Open Source Project
*
* 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 at
*
* 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 android.pim;
public class DateException extends Exception
{
public DateException(String message)
{
super(message);
}
}

View File

@@ -21,7 +21,6 @@ import com.android.internal.R;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.pim.DateException;
import java.util.Calendar;
import java.util.Date;
@@ -814,35 +813,6 @@ public class DateUtils
&& (thenMonth == time.month)
&& (thenMonthDay == time.monthDay);
}
/**
* @hide
* @deprecated use {@link android.text.format.Time}
*/
private static final int ctoi(String str, int index)
throws DateException
{
char c = str.charAt(index);
if (c >= '0' && c <= '9') {
return (int)(c - '0');
}
throw new DateException("Expected numeric character. Got '" +
c + "'");
}
/**
* @hide
* @deprecated use {@link android.text.format.Time}
*/
private static final int check(int lowerBound, int upperBound, int value)
throws DateException
{
if (value >= lowerBound && value <= upperBound) {
return value;
}
throw new DateException("field out of bounds. max=" + upperBound
+ " value=" + value);
}
/**
* @hide
@@ -861,81 +831,6 @@ public class DateUtils
return false;
}
// note that month in Calendar is 0 based and in all other human
// representations, it's 1 based.
// Returns if the Z was present, meaning that the time is in UTC
/**
* @hide
* @deprecated use {@link android.text.format.Time}
*/
public static boolean parseDateTime(String str, Calendar cal)
throws DateException
{
int len = str.length();
boolean dateTime = (len == 15 || len == 16) && str.charAt(8) == 'T';
boolean justDate = len == 8;
if (dateTime || justDate) {
cal.clear();
cal.set(Calendar.YEAR,
ctoi(str, 0)*1000 + ctoi(str, 1)*100
+ ctoi(str, 2)*10 + ctoi(str, 3));
cal.set(Calendar.MONTH,
check(0, 11, ctoi(str, 4)*10 + ctoi(str, 5) - 1));
cal.set(Calendar.DAY_OF_MONTH,
check(1, 31, ctoi(str, 6)*10 + ctoi(str, 7)));
if (dateTime) {
cal.set(Calendar.HOUR_OF_DAY,
check(0, 23, ctoi(str, 9)*10 + ctoi(str, 10)));
cal.set(Calendar.MINUTE,
check(0, 59, ctoi(str, 11)*10 + ctoi(str, 12)));
cal.set(Calendar.SECOND,
check(0, 59, ctoi(str, 13)*10 + ctoi(str, 14)));
}
if (justDate) {
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
return true;
}
if (len == 15) {
return false;
}
if (str.charAt(15) == 'Z') {
return true;
}
}
throw new DateException("Invalid time (expected "
+ "YYYYMMDDThhmmssZ? got '" + str + "').");
}
/**
* Given a timezone string which can be null, and a dateTime string,
* set that time into a calendar.
* @hide
* @deprecated use {@link android.text.format.Time}
*/
public static void parseDateTime(String tz, String dateTime, Calendar out)
throws DateException
{
TimeZone timezone;
if (DateUtils.isUTC(dateTime)) {
timezone = TimeZone.getTimeZone("UTC");
}
else if (tz == null) {
timezone = TimeZone.getDefault();
}
else {
timezone = TimeZone.getTimeZone(tz);
}
Calendar local = new GregorianCalendar(timezone);
DateUtils.parseDateTime(dateTime, local);
out.setTimeInMillis(local.getTimeInMillis());
}
/**
* Return a string containing the date and time in RFC2445 format.
* Ensures that the time is written in UTC. The Calendar class doesn't