Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Works in Java; Doesn't in Database

Works in Java; Doesn't in Database

From: <tariks_at_my-deja.com>
Date: Thu, 23 Nov 2000 10:16:03 GMT
Message-ID: <8viqp1$5fr$1@nnrp1.deja.com>

Hello

Now why would this be happening? I have a small java class to find the day in the week for any given date passed in. The class uses the parse method of the DateFormat class to determine if the passed in string is a valid date or not. If it isn't it throws the ParseException error.

When I run the class on my own machine in the JDK 1.2 environment the class correctly establishes the day in the week for valid dates. In the database environment the Java Stored Procedure always throws the ParseException error even when a valid date is passed in. I believe the database is running the JDK 1.1.8 environment.

Here's the class:

import java.text.*;
import java.util.*;

public class WhatDayInWeek
{

	public static String getDayOfWeek(String inputDate)
	{

		Calendar calendar;
		String day;
		Date thedate = new Date();

		// Get the passed in date and time
		try
		{

// Create a new date format...
DateFormat df = DateFormat.getDateInstance(); df.setLenient(true);
// Parse it to make sure it's in a valid format:
thedate = df.parse(inputDate);
// It's a valid date/time... create a Calendar
object: calendar = df.getCalendar();
// and set it to the date object version of the
date passed in: calendar.setTime(thedate);
// What day is it?
day = String.valueOf(calendar.get (Calendar.DAY_OF_WEEK));
//day = df.getDateTimeInstance(df.DEFAULT,
df.DEFAULT, locale).format(thedate); return day; } catch (ParseException e) {
//return "Invalid date!";
return inputDate; } }

}

And here's the Stored Procedure definition:

(p_datestring IN VARCHAR2)

RETURN VARCHAR2 IS LANGUAGE JAVA
NAME 'WhatDayInWeek.getDayOfWeek(java.lang.String) return java.lang.String';

So what's wrong?

Any ideas?

Thanks.

Tarik

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Thu Nov 23 2000 - 04:16:03 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US