Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Convert 2010-01-01 to 01-JAN-10 type here it 01-JAN-10 should be DATE datatype import java.text.*; import java.util.

*; public class Samp { public void DateFormatTest() { String dateString = "2001/03/09"; SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/mm/dd"); Date convertedDate; try { convertedDate = dateFormat.parse(dateString); SimpleDateFormat format2 = new SimpleDateFormat("dd-MMM-yy"); Date d = (Date) format2.format(convertedDate); System.out.println("Converted string to date : " + format2.format(convertedDate)); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void main(String[] argv) { Samp s = new Samp(); s.DateFormatTest(); } } 2010-01-01 to 01-JAN-10 YYYY-DD-MM to DD-MMM-YY Here i need DATE type of 01-JAN-10 public class Hello { public static String world() { return "Hello world"; } } Compile the class on your client system using the standard Java compiler, as follows:

javac Hello.java Load the class on the server using loadjava. You must specify the user name and password. Run the loadjava command as follows: loadjava -user scott/tiger Hello.class In SQL*Plus, connect to the database and define a top-level call specification for Hello.world() as follows: CREATE OR REPLACE FUNCTION helloworld RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'Hello.world () return java.lang.String'; / Call the stored procedure, as follows: SQL> VARIABLE myString VARCHAR2(20); SQL> CALL helloworld() INTO :myString; Call completed. SQL> PRINT myString; MYSTRING

You might also like