# Java Source
| create or replace and compile java source named JavaUtils as |
| package com.java.util; |
| import java.text.SimpleDateFormat; |
| import java.util.Date; |
| |
| public class JavaUtils { |
| public static void entry(){ |
| System.out.println(123); |
| } |
| |
| public static String getNowDate(String dateFormat) throws Exception { |
| if(dateFormat == null) dateFormat = "/"; |
| |
| return getNowYear("") + dateFormat + getNowMonth("") + dateFormat + getNowDay(""); |
| } |
| |
| public static String getNowYear(String dateFormat) throws Exception { |
| return new SimpleDateFormat("yyyy").format(new Date()); |
| } |
| |
| public static String getNowMonth(String dateFormat) throws Exception { |
| return new SimpleDateFormat("MM").format(new Date()); |
| } |
| |
| public static String getNowDay(String dateFormat) throws Exception { |
| return new SimpleDateFormat("dd").format(new Date()); |
| } |
| } |
# Create Function Test
| create or replace noneditionable function java_test(str in STRING) |
| |
| return string is language java name 'com.java.util.JavaUtils.getNowDate(java.lang.String) return java.lang.String'; |
| |
| |
| |
| |