Oracle 的months_between(函数)转成java代码

这是从网上复制的 不知道对不对
最好能解释下months_between(函数)的源码是怎么操作的
public class Months_between {

/**
 * 计算两个日期相差的月份数
 *
 * @param date1 日期1
 * @param date2 日期2
 * @param pattern  日期1和日期2的日期格式
 * @return 相差的月份数
 * @throws
 */
private Date date1;
private Date date2;

public static int countMonths(String date1, String date2, String pattern) throws ParseException {
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);

    Calendar c1 = Calendar.getInstance();
    Calendar c2 = Calendar.getInstance();

    c1.setTime(sdf.parse(date1));
    c2.setTime(sdf.parse(date2));

    int year = c2.get(Calendar.YEAR) - c1.get(Calendar.YEAR);

    /*//开始日期若小月结束日期
    if (year < 0) {
        year = -year;
        return year * 12 + c1.get(Calendar.MONTH) - c2.get(Calendar.MONTH);
    }*/

    return year * 12 + c2.get(Calendar.MONTH) - c1.get(Calendar.MONTH);
}

}

3个回答

因为是两个日期差,所以可能第一个大,也可能第二个大,所以if (year < 0) 后需要颠倒下
year * 12 + c2.get(Calendar.MONTH) - c1.get(Calendar.MONTH);
颠倒下就是
-year * 12 - c2.get(Calendar.MONTH) + c1.get(Calendar.MONTH);
也就是
return -year * 12 + c1.get(Calendar.MONTH) - c2.get(Calendar.MONTH);
也就是
year = -year;
return year * 12 + c1.get(Calendar.MONTH) - c2.get(Calendar.MONTH);

caozhy
贵阳老马马善福专门编写代码的老马就是我! 回复qq_39906279: ?
一年多之前 回复
qq_39906279
qq_39906279 c1和穿同年
一年多之前 回复

计算两个月差多少个月。
思路是
int year = c2.get(Calendar.YEAR) - c1.get(Calendar.YEAR);
先算出差多少整年,year * 12
再加上头尾差多少个月c1.get(Calendar.MONTH) - c2.get(Calendar.MONTH);

比如2016年8月到2018年4月
那么year=2
月份相差是-4
结果就是2*12+(-4)=20个月

假设c1是2018-4-25
c1.get(Calendar.MONTH) 返回4
c1.get(Calendar.YEAR) 返回 2018

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
oracle月数年数专用函数months_between
求时间差月数 floor(months_between(sysdate, date)) 求时间差年数 floor(months_between(sysdate, date) / 12) years
Oracle日期函数months_between的用法
select months_between(sysdate,to_date('2015-08-14','yyyy/mm/dd')) from dualmonths_between(参数1,参数2),返回的是两日期差的月份数, (1)若两参数一致,返回为0select months_between(sysdate,to_date('2015-08-14','yyyy/mm/dd')) from du
oracle中months_between用法
sql语句中用trunc((months_between(trunc(date1,'mmm'),trunc(date3,'mm')))/12)计算相差多少年,返回的结果为:rnrn17年0月rn13年1月rn28年3月rnrn以前都只返回rn17rn13rn28rnrn哪位大侠指点一下rnrn
months_between
select rnsum(case when rn trunc(months_between(to_date(to_char(sysdate,'YYYYMMDD'),'YYYYMMDD'),to_date(date_in,'YYYYMMDD')))<=1rn then 1 rn else 0rn endrn) from pe_personrn我想筛选date_in时间不满一年的所有记录!这样做不行。求解,谢谢!
sql函数6(last_day,months_between函数)
如果你刚刚了解Oracle,本门课程将是你不二的选择,该课程将带你走进Oracle的大门,本课程以接地气的语言来讲解,让你听的懂,学的会!本课程以全新的方式为你呈现Oracle内容,清新脱俗独具特色的授课方式将带给你新的体验。
java代码DES加密函数转成C#版的
求大神把java代码DES加密函数,翻译成C#版的,网上的代码加密出来,结果不一样。key好像经过了一次md5加密,哪位大牛能翻译成C#版的啊???rn rn [code=Java]public static String DESDecrypt(String data, String key, String encoding)rnrn String edata = data;rn tryrn rn MessageDigest digest = MessageDigest.getInstance("MD5");rnrn digest.update(key.getBytes(encoding));rn DESedeKeySpec dks = new DESedeKeySpec(convert16To24(digest.digest()));rn SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DESede");rn SecretKey securekey = keyFactory.generateSecret(dks);rn Cipher cipher = Cipher.getInstance("DESede/ECB/PKCS5Padding");rn cipher.init(Cipher.DECRYPT_MODE , securekey, new SecureRandom());rn if (!data.endsWith( "=" ))rn rn data = URLDecoder.decode(data, encoding);rn rn edata = new String(cipher.doFinal(BASE64Decrypt(data)), encoding);rn rn catch (Exception e)rn rn e.printStackTrace();rn rn return edata;rnrnrnrn/**rn* BASE64 解密rn*rn* @param keyrn* @returnrn* @throws Exceptionrn*/rnpublic static byte [] BASE64Decrypt(String data)rnrn byte [] edata = null ;rn tryrn rn edata = ( new BASE64Decoder()).decodeBuffer(data);rn rn catch (Exception e)rn rn e.printStackTrace();rn rn return edata;rnrnrnrn/**rn* 把 16 位凑成 24 位数组。rn*rn* @param okeyrn* @returnrn*/rnprivate static byte [] convert16To24(byte [] okey)rnrn byte [] dkey = new byte [24];rn for (int i = 0; i < dkey. length ; i++)rn rn dkey[i] = okey[i % 16];rn rn return dkey;rnrnrn[/code]
在DB2中有类似于ORACLE中的months_between函数吗
请教下朋友们:rn在DB2中有类似于ORACLE中的months_between函数吗rn
JAVA代码转成C#
/** 把图像以1或0方式打印 */ rn public static void printImageToDots(String filePath) throws Exception rn File file = new File(filePath); rn BufferedImage read = ImageIO.read(file); rn WritableRaster raster = read.getRaster(); rn int pixelSize = read.getColorModel().getPixelSize(); rn System.out.println("==像素==" + pixelSize); rn if (pixelSize > 2) rn return; rn rn int width = read.getWidth(); rn int height = read.getHeight(); rn int[] pixels = new int[width]; rn StringBuffer sb = new StringBuffer(); rn for (int i = 0; i < height; i++) rn Arrays.fill(pixels, 0xFF); rn raster.getPixels(0, i, width, 1, pixels); rn int[] p1 = getBytes(pixels); rn for (int j = 0; j < p1.length; j++) rn java.text.DecimalFormat df = new java.text.DecimalFormat( rn "00000000"); rn sb.append(df.format(Integer.valueOf(Integer rn .toBinaryString(p1[j])))); rn rn sb.append("\n"); rn rn System.out.println(sb.toString()); rn
将java代码转成C#
/** 把图像以1或0方式打印 */rn public static void printImageToDots(String filePath) throws Exception rn File file = new File(filePath);rn BufferedImage read = ImageIO.read(file);rn WritableRaster raster = read.getRaster();rn int pixelSize = read.getColorModel().getPixelSize();rn System.out.println("==像素==" + pixelSize);rn if (pixelSize > 2) rn return;rn rn int width = read.getWidth();rn int height = read.getHeight();rn int[] pixels = new int[width];rn StringBuffer sb = new StringBuffer();rn for (int i = 0; i < height; i++) rn Arrays.fill(pixels, 0xFF);rn raster.getPixels(0, i, width, 1, pixels);rn int[] p1 = getBytes(pixels);rn for (int j = 0; j < p1.length; j++) rn java.text.DecimalFormat df = new java.text.DecimalFormat(rn "00000000");rn sb.append(df.format(Integer.valueOf(Integerrn .toBinaryString(p1[j]))));rn rn sb.append("\n");rn rn System.out.println(sb.toString());rn rnrnrn////////////////////////////////////////rnrn private static Object imagePixelToPos(BufferedImage bmp, int m, int dots, rn int widthRange, Object toReturn) throws Exception rn //------------- 图像的基本属性 ---------------- rn int width = bmp.getWidth(); rn int height = bmp.getHeight(); rn int nl = width % 256; rn int nh = width / 256; rn int ch = (height + dots - 1) / dots; rn if (width > widthRange) rn throw new Exception("==图像宽度超打印范围=="); rn rn //====================END====================== rn rn //------------- 输出String或Byte形式的POS命令 ---------------- rn StringBuffer sb = null; rn ByteArrayOutputStream baos = null; rn String cmdStr1 = null; rn String cmdStr2 = ", (byte)0x0A, \n"; rn int[] cmdByte1 = new int[] 0x1B, 0x2A, m, nl, nh ; rn int[] cmdByte2 = new int[] 0x0A ; rn if (toReturn instanceof String) rn sb = new StringBuffer(); rn cmdStr1 = "(byte)0x1B, (byte)0x2A, (byte)0x%s, (byte)0x%s, (byte)0x%s"; rn cmdStr1 = String.format(cmdStr1, new Object[] rn Integer.toHexString(m), Integer.toHexString(nl), rn Integer.toHexString(nh) ); rn else if (toReturn instanceof byte[]) rn baos = new ByteArrayOutputStream(); rn else rn baos = new ByteArrayOutputStream(); rn rn //=======================END================================== rn //获得像素Raster rn Raster raster = getRaster(bmp); rn rn //按列取点 rn int[] p3 = new int[dots]; rn for (int h = 0; h < ch; h++) rn //------- 输出POS命令 ESC * m nl nh -------- rn if (sb != null) rn posCmd(sb, cmdStr1); rn else if (baos != null) rn posCmd(baos, cmdByte1); rn rn //===================END====================== rn for (int w = 0; w < width; w++) rn //值填充,白点 rn Arrays.fill(p3, 0xFF); rn raster rn .getPixels(w, h * dots, 1, rn (h + 1 == ch ? height - dots * h : dots), rn p3); rn rn //把每8个点输出成一个字节 rn int[] bytes = getBytes(p3); rn //把每个字节以POS命令形式输出 rn if (sb != null) rn resultStratergy(sb, bytes); rn else if (baos != null) rn resultStratergy(baos, bytes); rn rn rn //------- 输出POS命令 0x0A -------- rn if (sb != null) rn posCmd(sb, cmdStr2); rn else if (baos != null) rn posCmd(baos, cmdByte2); rn rn //===============END================= rn rn //------- 字符串修正 -------- rn if (sb != null && sb.length() > 3) rn sb.setLength(sb.length() - 3); rn String toString = sb.toString(); rn System.out.println(toString); rn rn //=============END============ rn return sb == null ? baos.toByteArray() : sb.toString(); rn rnrn
.net转成JAVA代码
if (Request.QueryString["layername"] == null && Request.QueryString["keyvalue"] == null) return; rnrn string Url = "http://10.22.112.21:8719/NewMapServer/WebServices/FeatureServer.php?layer=" + Request.QueryString["layername"] .ToString() rn + "&request=query&WHERE"; rn string whereClause = "= 名称 LIKE '%" + Request.QueryString["keyvalue"] .ToString()+ "%'"; rn whereClause = Server.HtmlEncode(whereClause); rnrn HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url+whereClause); rn request.Timeout = 30000; rn request.Headers.Set("Pragma", "no-cache"); rn HttpWebResponse response = (HttpWebResponse)request.GetResponse(); rn Stream streamReceive = response.GetResponseStream(); rn Encoding encoding = Encoding.GetEncoding("UTF-8"); rn StreamReader streamReader = new StreamReader(streamReceive, encoding); rn string strResult = streamReader.ReadToEnd(); rn streamReader.Close(); rn _jsonStr=strResult; rnrn上面是一段.NET代码,请问各位能不能帮我翻译成JAVA代码啊 rnrnHttpWebRequest 到底对应JAVA中的哪个对象啊
关于oracle中MONTHS_BETWEEN(data2,data1)函数的问题?
我今天用到了select months_between(to_date('2006-05-17','YYYY-MM-DD'),to_date('2006-01-01',YYYY-MM-DD')) from dual;这个函数时。得出的结果是一个带有小数位的数。请问为什么不是按月来减的。它至底是怎么算的?哪位帮我解释一下。谢谢!!!
汉字转成拼音 Java代码
汉字转成拼音 Java代码,很完整的啊
将C# 转成Java代码
如题。求大神帮帮忙。谢谢。。。rn 1 using System;rn 2 using System.Data;rn 3 using System.Configuration;rn 4 using System.Web;rn 5 using System.Web.Security;rn 6 using System.Web.UI;rn 7 using System.Web.UI.WebControls;rn 8 using System.Web.UI.WebControls.WebParts;rn 9 using System.Web.UI.HtmlControls;rn10 using System.Diagnostics;rn11 using System.IO;rn12 rn13 /// rn14 /// Pdf2Swf 将pdf转化为swfrn15 /// rn16 public class Pdf2Swfrn17 rn18 public Pdf2Swf()rn19 rn20 //rn21 // TODO: 在此处添加构造函数逻辑rn22 //rn23 rn24 public void PDFConvertToSWF(string sourcePath, string targetPath)rn25 rn26 Process p = new Process();rn27 p.StartInfo.FileName = "cmd.exe ";rn28 p.StartInfo.UseShellExecute = false;rn29 p.StartInfo.RedirectStandardInput = true;rn30 p.StartInfo.RedirectStandardOutput = true;rn31 p.StartInfo.RedirectStandardError = true;rn32 p.StartInfo.CreateNoWindow = true;rn33 p.Start();rn34 string cmd = "pdf2swf.exe" + " " + sourcePath + " -o " + targetPath;rn35 p.StandardInput.WriteLine(cmd);rn36 p.Close();rn37 rn38 rnrnrn需要知道转换过的java 代码应该怎么写
CRC的JAVA代码转成C++?
请问如何将下面的JAVA代码转成C++的,谢谢了先~rn[code=Java]Generate the CRC Lookup Tablernvoid generateCRCTable() rnint i, j, data, accumulator;rnfor (j=0; j<256; j++) rndata = j;rnaccumulator = 0;rndata <<= 8;rnfor (i=8; i>0; i--) rnif (((data ^ accumulator) & 0x8000) > 0)rnaccumulator = (accumulator << 1) ^ 0x1021;rnelsernaccumulator <<= 1;rndata <<= 1;rnrnthis.crcTable[j] = accumulator;rnrnrnRetrieve a CRC ValuernString getCRC(byte[] arg) rnint i, accumulator, data, index;rnString returnValue = new String();rnaccumulator = 0xffff;rnfor (i=0; i> 8) ^ data;rnaccumulator = (accumulator << 8) ^ this.crcTable[index];rnrnaccumulator ^= 0xffff;rnreturnValue = Integer.toHexString(accumulator).toUpperCase();rnfor (i=returnValue.length(); i<4; i++)rnreturnValue = '0' + returnValue;rnreturn returnValue;rnrnGenerating a Full Command Stringrnpublic String generateCommandString(char commandCharacter,rnString dataSection) rnString stringToSend;rnchar[] commandString = 0x01, '0', commandCharacter, 0x02;rnstringToSend = new String(commandString) +rndataSection + (char) 0x03;rnstringToSend += getCRC(stringToSend.getBytes());rnWWW.JAMEXVENDING.COMrn14rnreturn stringToSend;rn[/code]
onvif wsdl转成java代码
onvif协议的开发,wsdl转成为java包,导入eclipse即可使用,可二次开发
c++转成java代码
int abc(unsigned char *data, int length)rnrn unsigned char * p = data;rn unsigned char * pz = data+length;rnrn while (p
PHP代码转成java代码
-
Oracle日期函数add_months()、last_day()、months_between()的用法
add_months(date,n) 返回指定日期date加上n月后的日期 select add_months(to_date('20190321','yyyyMMdd'),22) from dual;--返回2021/1/21 last_day(date,n) 返回指定日期date减去n个月后的日期 select last_day(to_date('20190321','yyyyMM...
请问:date 函数: months_between 的值怎末计算出来的?
我在复习007 ,请问months_between()的数值怎末计算出来的?rn 例如:months_between('01-sep-95','11-jan-94') 答案是19.6774194 怎末得出来的?
求c++代码转成java代码⋯⋯⋯⋯
#includen#includen#includenusing namespace std;nstruct studentnn char name[11];n int solve;n int cost;nstu[10000];nbool cmp(student a,student b)nn if(a.solve!=b.solve)n if(a.solve>b.solve)n return true;n elsen return false;n else if(a.cost==b.cost)n n return(strcmp(a.name,b.name)<0);n n n elsen n return(a.cost>n>>m)n n int t=0;n while(cin>>stu[t].name)n n if(strcmp(stu[t].name,"eof")==0)n break;n for(i=0;i>s;n if(s>0)n n stu[t].solve++;n k=0;n if(getchar()=='(')n n cin>>k;n cin>>ch;n n stu[t].cost=stu[t].cost+s+k*m;n n n t++;n n sort(stu,stu+t,cmp);n for(i=0;i
江湖救急 pb代码转成java代码
string ls_bankrnrnstring ls_Bank_Idrnstring ls_header120,ls_Body100,ls_check60,ls_tail232rnInteger li_herder[1 to 40]rnInteger li_Body10_10[1 to 10,1 to 10]rnInteger li_check6_10[1 to 6,1 to 10],li_check_6_10[1 to 6,1 to 10]rnInteger i,j,k,temp_i,temp_jrnrnInt li_Body34[1 to 34]rnrnstring ls_prnls_header120=mid(as_password,1,120)rnls_Body100 =mid(as_password,121,100)rnls_check60 =mid(as_password,221,60)rnls_tail232 =mid(as_password,281,232)rnrnfor i=1 to 40rn li_herder[i]=Integer(mid(ls_header120,i*3 - 2,3))rn if i<=34 then rn li_Body34[i]=Integer(mid(ls_Body100,i*3 - 2,3))rn li_Body34[i]=li_Body34[i] - li_herder[i]rn end ifrnnextrnli_Body34[34]=48rnrnfor i=1 to 10rn for j=1 to 10rn li_Body10_10[i,j] = Integer(mid(ls_Body100,(i -1)*10+j,1)) rn next rnnextrnrnfor i=1 to 6 //加密矩阵的方式: - | \ / N Zrn for j=1 to 10rn li_check6_10[i,j] = mod(Integer(mid(ls_check60,(i -1)*10+j,1)) ,10)rn next rnnextrnrn//-----------------------------------------------------------------------------------rnfor i=1 to 10rn for k=1 to 6rn li_check_6_10[K,i]=0rn NextrnNextrnrnfor i=1 to 10rn for j=1 to 10rn ls_p=ls_p+String(li_Body10_10[j,i])/////////rn for k=1 to 6 rn Choose Case krn case 1 // - rn li_check_6_10[K,i] =li_check_6_10[K,i]+li_Body10_10[i,j]rn li_check_6_10[K,i] = mod(li_check_6_10[K,i],10)rn case 2 // | rn li_check_6_10[K,i] =li_check_6_10[K,i]+li_Body10_10[j,i]rn li_check_6_10[K,i] = mod(li_check_6_10[K,i],10)rn Case 3 // \ rn li_check_6_10[K,i] =li_check_6_10[K,i]+li_Body10_10[j,mod(i+j -1,10)+1]rn li_check_6_10[K,i] = mod(li_check_6_10[K,i],10)rn Case 4 // / rn li_check_6_10[K,i] =li_check_6_10[K,i]+li_Body10_10[j,mod(10 - j +i,10)+1]rn li_check_6_10[K,i] = mod(li_check_6_10[K,i],10)rn Case 5 // N rn temp_j = mod(i + mod(j+1,2)- 1 ,10) +1rn li_check_6_10[K,i] =li_check_6_10[K,i]+li_Body10_10[j,temp_j]rn li_check_6_10[K,i] = mod(li_check_6_10[K,i],10)rn Case 6 // Z rn temp_j = mod(10 + i - mod(j+1,2)- 1 ,10) +1rn li_check_6_10[K,i] =li_check_6_10[K,i]+li_Body10_10[j,temp_j]rn li_check_6_10[K,i] = mod(li_check_6_10[K,i],10) rn End Choose rn next rn ls_p=left(ls_p+String(li_Body10_10[j,i]),12)/////////rn nextrnNextrnrnrnfor i=1 to 6rn for j=1 to 10rn if li_check6_10[i,j]<>li_check_6_10[i,j] thenrn ls_p='abc1234567'rn End ifrn nextrnnextrnrn//-----------------------------------------------------------------------------------rngs_Bank_Id = ProfileString( gs_Ini_File, "Common", "bank", "")rnls_Bank_Id=left(gs_Bank_Id,20)rnrnli_herder[40]=li_herder[40]/10rn//messageBox('',char(li_Body34[1]) + char(li_Body34[2]) )rn//messageBox('',char(li_Body34[3]) + char(li_Body34[4]) )rn//messageBox('',char(li_Body34[5]) + char(li_Body34[6]) )rnls_bank = ''rnrnfor i=1 to len(gs_Bank_Id)rn ls_bank=ls_bank+Char(li_Body34[i])rnNextrnrnif ls_bank = gs_Bank_Id then rn for i=len(ls_bank)+1 to li_herder[40]rn ls_p=ls_p+ Char(li_Body34[i])rn NextrnEnd ifrnrnls_p=mid(ls_p,13)//截取指定字符串 arg0 要截取的字符串 arg1 截取长度rnreturn ls_p
!!!将java代码转成C#代码!!!
rnpublic void invoke(MessageContext context) throws Exception rn final Namespace ns = Namespace.getNamespace("xa", "http://service.xfire.module.webservice.xa.com");rn Element el = new Element("header", ns);rnrn Element auth = new Element("AuthenticationToken", ns);rn Element username_el = new Element("Username", ns);rn username_el.addContent(username);rn Element password_el = new Element("Password", ns);rn password_el.addContent(password);rn auth.addContent(username_el);rn auth.addContent(password_el);rn el.addContent(auth);rn context.getCurrentMessage().setHeader(el);rn rnrn请大虾们帮帮忙,将上面代码转成C#代码,谢谢!!
Oracle调用Java代码过程
本资源为个人结合网上资料,试验成功。 Oracle后台存储过程中调用Java代码块,以此来访问异构数据库数据(DB2)。 此方式适用场景: 原有业务逻辑均在后台实现,现要加入对异构数据库的数据访问或写入。 异构数据库的访问,多用数据联邦、透明网关或自行编写JDBC访问代码。但如果逻辑原有在Oracle数据后台,又无法采购专业的连接软件套件,则此方式较为有用。敬请收藏。
Oracle 分页存储过程Java代码
这是我的存储过程(Oracle) CREATE OR REPLACE PROCEDURE query_findpage (p_tableName in varchar2, --表名 p_column in varchar2, --查询的列 p_Where in varchar2, ...
oracle转成postgre时,oracle中函数的处理工具(orafce)
NULL 博文链接:https://moooneee.iteye.com/blog/442478
Oracle中执行java代码
1.在ORACLE数据库中创建功能类(实现签名): create or replace and compile java source named TestName as public class SingleName { public static String testStr=&quot;Test Str&quot;; public static void entry() { } ...
oracle 存储过程 转换java代码
beginrnrn select count(1) into v_ply_table_countrn from user_tables user_trn where lower(user_t.table_name) = 'cust_temp_ply_base';rnif v_ply_table_count = 0rn thenrn execute immediate 'create table CUST_TEMP_PLY_BASErn (rn C_PLY_NO nvarchar2(100),rn C_ORIG_FLG int,rn C_ORIG_PLY_NO nvarchar2(100),rn C_PROD_NO nvarchar2(20),rn C_DPT_CDE nvarchar2(100),rn C_SLS_CDE nvarchar2(100),rn c_oper_cde nvarchar2(100),rn T_INSRNC_BGN_TM date,rn T_INSRNC_END_TM datern )';rn execute immediate 'alter table CUST_TEMP_PLY_BASErn add constraint PK_TEMP_PLY_PK primary key (C_PLY_NO)rn using indexrn tablespace CRM_CLEANrn pctfree 10rn initrans 2rn maxtrans 255rn storagern (rn initial 768Krn minextents 1rn maxextents unlimitedrn )';rnend if;rnrnexecute immediate 'truncate table CUST_TEMP_PLY_BASE';rnrnselect count(1) into v_edr_table_countrn from user_tables user_t where user_t.table_name = 'CUST_TEMP_EDR_BASE';rnrnif v_edr_table_count = 0rn thenrn execute immediate 'create table CUST_TEMP_EDR_BASErn (rn C_EDR_NO nvarchar2(100),rn C_PLY_NO nvarchar2(100),rn c_edr_type intrn )';rn execute immediate 'alter table CUST_TEMP_EDR_BASErn add constraint PK_TEMP_EDR_PK primary key (C_EDR_NO)rn using indexrn tablespace CRM_CLEANrn pctfree 10rn initrans 2rn maxtrans 255rn storagern (rn initial 768Krn minextents 1rn maxextents unlimitedrn )';rnend if;rn execute immediate 'truncate table CUST_TEMP_EDR_BASE';rnrn--导入数据--ODS批单有效数据rninsert into CUST_TEMP_EDR_BASErn(rn C_EDR_NO,rn C_PLY_NO,rn c_edr_typern)rnselectrn edr.C_EDR_NO,rn edr.C_PLY_NO,rn edr.c_edr_typernfrom ply_info plyrn left join v_core_edr_base edrrn on ply.policy_no = edr.C_PLY_NOrnwherern(rn edr.c_edr_type is nullrn or edr.C_EDR_TYPE = 1rn or edr.c_edr_type = 2rn)rnand edr.c_edr_no is not null;rncommit;rnrnrn--导入数据--ODS保单有效数据rninsert into CUST_TEMP_PLY_BASErn(rn C_PLY_NO,rn C_ORIG_FLG,rn C_ORIG_PLY_NO,rn C_PROD_NO,rn C_DPT_CDE,rn C_SLS_CDE,rn c_oper_cde,rn T_INSRNC_BGN_TM,rn T_INSRNC_END_TMrn)rnselectrn base.C_PLY_NO,rn base.C_ORIG_FLG,rn base.C_ORIG_PLY_NO,rn base.C_PROD_NO,rn base.C_DPT_CDE,rn base.C_SLS_CDE,rn base.c_oper_cde,rn base.T_INSRNC_BGN_TM,rn base.T_INSRNC_END_TMrnfrom ply_info plyrn inner join v_core_ply_base basern on ply.policy_no = base.C_PLY_NO;rnrn--清除导入保单数据中注销和退保的保单rndelete from CUST_TEMP_PLY_BASE plyrnwhere ply.c_ply_no inrn (rn select distinct(ply_base.c_ply_no)rn fromrn v_core_ply_base ply_basern left join v_core_edr_base edrrn on ply_base.c_ply_no = edr.C_PLY_NOrn wherern edr.C_EDR_TYPE = 3rn orrn edr.c_edr_type = 4rn );rnrncommit;rnend;rnrn这段存储过程 如何 转换java代码 rnrn希望高人 指点 必有重谢!!!
在Oracle中插入java代码??
请问:再Oracle中怎么去实现java编程!???
“case when”语法和sql中使用“months_between”函数 (2)
第一次见到这个函数即是在这个sql文中。。。。。。。。。。。months_between(date1,date2):用来计算两个日期之间相隔几个月的函数;如果date1的日期在date2之后,那么此函数返回一个正数;如果date1的日期在date2之前,那么此函数返回一个负数;如果date1和date2日期相等,那么此函数返回一个0;两个日期之间相差多少个月,返回数值就是几。如果日期的日数并不相等...
如何把Kotlin代码转成Java代码、把Java代码转成Kotlin代码
Java转Kotlin打开File –> Settings –> Plugins选项,输入“Kotlin”搜索插件,安装成功重启Android Studio 选中需要转换的文件或者包 Code –> Convert Java File To Kotlin File 注意:Convert Java File To Kotlin File为灰色的几种情况 Kotlin插件未安装 选中的文件已是kot
PHP 函数 转成 ASP函数
本人对ASP比较熟悉!rnPHP玩不来!今天需要将一个PHP函数转为ASP函数!rn望各位高手帮帮忙!就两个函数!rnfunction u2utf8($c)rnrnfor($i=0;$i>6);rn$str.=(0x80 | $c & 0x3F);rnrnelse if ($c < 0x10000) rn$str.=(0xE0 | $c>>12);rn$str.=(0x80 | $c>>6 & 0x3F);rn$str.=(0x80 | $c & 0x3F);rnrnelse if ($c < 0x200000) rn$str.=(0xF0 | $c>>18);rn$str.=(0x80 | $c>>12 & 0x3F);rn$str.=(0x80 | $c>>6 & 0x3F);rn$str.=(0x80 | $c & 0x3F);rnrnreturn $str;rnrnrnfunction gb2utf8($gb) /* Program writen by sadly modified by agun */rnrnif(!trim($gb))rnreturn $gb;rn$filename="gb2312.txt";rn$tmp=file($filename);rn$codetable=array();rnwhile(list($key,$value)=each($tmp))rn$codetable[hexdec(substr($value,0,6))]=substr($value,7,6);rnrn$ret="";rn$utf8="";rnwhile($gb)rnrnif (ord(substr($gb,0,1))>127)rnrn$this=substr($gb,0,2);rn$gb=substr($gb,2,strlen($gb));rn$utf8=u2utf8(hexdec($codetable[hexdec(bin2hex($this))-0x8080]));rnfor($i=0;$i
如何把Kotlin代码转成java代码,如何把java代码转成kotlin代码
其实就是互转,以下基于IDEA或Android StudioJava转Kotlin打开要转的文件方法1Ctrl+Shift+Alt+K方法2Code - Convert Java File To Kotlin FileKotlikn 转 Java Tools>Kotlin>Show Kotlin Bytecode Decompile
delphi 函数转成 c 函数
[code=delphi]kp_GetSysInitStatus(var InitStatus:byte):integerrn2.获取初始化状态rnvarrn re:integer;rn sTmp:string;rn bStatus:byte;rnbeginrn memo1.Lines.Add('获取系统初始化状态...');rn re:=kp_GetSysInitStatus(bStatus);rn sTmp:= inttostr(bStatus);rn memo1.Lines.Add('状态(1-已初始化,0-未初始化):'+sTmp);rn[/code]rnrn又说返回值是re 还是sTmp???rn转化成c该是什么样的?求解
求把这段JAVA代码转成C#的,谢谢!
[code=Java]rnString apikey = "111111111111111111111111111111"; rnString isbnUrl = "http://api.douban.com/book/subject/isbn/"; rn rnpublic static void main(String[] args) throws Exception rn //requestUrl = isbnUrl + isbnNo + "?apikey=" + apikey; rn //eg:http://api.douban.com/book/subject/isbn/9787111298854?apikey=111111111111111111114 rn ISBN isbnTest = new ISBN(); rn String isbnNo = "9787111298854"; rn String xml = isbnTest.fetchBookInfoByXML(isbnNo); rn System.out.println(xml); rn rn rn/** rn * 从根据isbn号从豆瓣获取数据。已经申请apikey,每分钟最多40次请求,足够用。 rn * @param isbnNo rn * @return rn * @throws IOException rn */ rnpublic String fetchBookInfoByXML(String isbnNo) throws IOException rn String requestUrl = isbnUrl + isbnNo + "?apikey=" + apikey; rn URL url = new URL(requestUrl); rn URLConnection conn = url.openConnection(); rn InputStream is = conn.getInputStream(); rn InputStreamReader isr = new InputStreamReader(is, "utf-8"); rn BufferedReader br = new BufferedReader(isr); rn StringBuilder sb = new StringBuilder(); rn rn String line = null; rn while ((line = br.readLine()) != null) rn sb.append(line); rn rn rn br.close(); rn return sb.toString(); rn rnrn[/code]
使用Xamarin.Android转成java代码,pageck大小写问题
实在受不了Xamarin.Android上太多的坑了!! 于是我决定转java来写安卓rnrn但是,却遇到了一个问题rn我之前用C#的方式,给包名弄了个大写字母在包名里,于是在转成android时,编译不通过,因为包名的问题是大写的导致。改成小写就解决了。。。rnrnrn在AndroidManifest中只要报名是大写的就会部署失败rnrn但是,以前已经安装了APP的用户无法实现自动更新,求大神赐教rn
关于AES解密,java代码转成c++代码
客户提供了java的实现aes的代码,然后需要我这边c++实现解密rnrnrn我在网上找了各种c++的aes算法,甚至包括Crypto++开源代码,结果发现产生的密文都是二进制数据,而客户提供的密文都是可显示字符,密文如下:rnrn1oEqdH8vYSxza/LINXTbu8H86ssc7tkO227qErhtV+K/HNGBjZLrgA0loYTVQU505BQj078b9Mehcy1qfvGmiJxNZO1GsfN2ey0ActInMBw=rnrn我是什么地方搞错了?rnrn附带java源码rnrn[code=java]rnrnpackage test;rnrnimport java.io.UnsupportedEncodingException;rnimport java.security.InvalidAlgorithmParameterException;rnimport java.security.InvalidKeyException;rnimport java.security.NoSuchAlgorithmException;rnimport java.security.spec.AlgorithmParameterSpec;rnrnimport javax.crypto.BadPaddingException;rnimport javax.crypto.Cipher;rnimport javax.crypto.IllegalBlockSizeException;rnimport javax.crypto.NoSuchPaddingException;rnimport javax.crypto.spec.IvParameterSpec;rnimport javax.crypto.spec.SecretKeySpec;rnrnpublic class AspireAes rn private static AspireAes instance = null;rnrn private Cipher cipher;rnrn SecretKeySpec key = null;rnrn AlgorithmParameterSpec iv = null;rnrn public static AspireAes getInstance() rn String key = "0123456789abcdef0123456789abcdef", iv = "0123456789abcdef0123456789abcdef";rn if (instance == null) rn instance = new AspireAes(key, iv);rn rn return instance;rn rnrn /**rn * 将32bytes的16禁止串压缩成16bytes,充分利用128bits的密钥空间rn * rn * @param hexrn * @return byte[]rn */rn private static byte[] packHex(String hex) rn int len = hex.length() >> 1;rn byte[] b = new byte[len];rn short k = 0;rn for (int i = 0, j = 0; i < len; i++, j = i << 1) rn k = Short.parseShort(hex.substring(j, j + 2), 16);rn b[i] = (byte) (k & 0xff);rn rn return b;rn rnrn private AspireAes(String keyStr, String ivStr) rn try rn iv = new IvParameterSpec(packHex(ivStr));rn key = new SecretKeySpec(packHex(keyStr), "AES");rn cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");rnrn catch (NoSuchAlgorithmException e) rn e.printStackTrace();rn catch (NoSuchPaddingException e) rn e.printStackTrace();rn rn rnrn /**rn * 加密rn * rn * @param Stringrn * txtrn * rn * @return Stringrn */rn public byte[] encrypt(byte[] txt) rn try rn cipher.init(Cipher.ENCRYPT_MODE, key, iv);rn return cipher.doFinal(txt);rn catch (IllegalBlockSizeException e) rn e.printStackTrace();rn catch (BadPaddingException e) rn e.printStackTrace();rn catch (InvalidKeyException e) rn e.printStackTrace();rn catch (InvalidAlgorithmParameterException e) rn e.printStackTrace();rn rn return null;rn rnrn /**rn * 加密rn * rn * @param Stringrn * txtrn * rn * @return Stringrn */rn public String encrypt(String txt) rn try rn byte[] b = this.encrypt(txt.getBytes("utf-8"));rn return Base64.encodeToString(b, 0, b.length, Base64.NO_WRAP);rn catch (UnsupportedEncodingException e) rn e.printStackTrace();rn rn return null;rn rnrn /**rn * 加密rn * rn * @param Stringrn * txtrn * rn * @return Stringrn */rn public byte[] decrypt(byte[] txt) rn try rn cipher.init(Cipher.DECRYPT_MODE, key, iv);rn return cipher.doFinal(txt);rn catch (IllegalBlockSizeException e) rn e.printStackTrace();rn catch (BadPaddingException e) rn e.printStackTrace();rn catch (InvalidKeyException e) rn e.printStackTrace();rn catch (InvalidAlgorithmParameterException e) rn e.printStackTrace();rn rn return null;rn rnrn /**rn * 加密rn * rn * @param Stringrn * txtrn * rn * @return Stringrn */rn public String decrypt(String txt) rnrn try rn cipher.init(Cipher.DECRYPT_MODE, key, iv);rn byte[] b = txt.getBytes();rn b = Base64.decode(b, 0, b.length, Base64.NO_WRAP);rn b = cipher.doFinal(b);rn return new String(b, "utf-8");rn catch (IllegalBlockSizeException e) rn e.printStackTrace();rn catch (BadPaddingException e) rn e.printStackTrace();rn catch (InvalidKeyException e) rn e.printStackTrace();rn catch (InvalidAlgorithmParameterException e) rn e.printStackTrace();rn catch (UnsupportedEncodingException e) rn e.printStackTrace();rn rn return null;rn rnrn public static void test() rn String txt = "JCE中支持AES,支持的模式和填充方式JCE中AES支持五中模式:CBC,CFB,ECB,OFB,PCBC;支持三种填充:NoPadding,PKCS5Padding,ISO10126Padding。不支持SSL3Padding。不支持“NONE”模式";rn AspireAes aes = AspireAes.getInstance();rn String x = aes.encrypt(txt);rn System.out.print("加密:" + txt + "\t\t" + x+"\r\n");rn txt=x;rn x = aes.decrypt(txt);rn System.out.print("解密:" + txt + "\t\t" + x+"\r\n");rnrn rnrn /**rn * @param argsrn */rn public static void main(String[] args) rn test();rn rnrnrnrn[/code]
急....C语言代码转成java代码
[code=C/C++]rnvoid GetChkSum(Int len, PSTR buf, PSTR res)rnrn memset(res, 0, 8); //IIN格式的校验码为8字节rn for(int i=0; i"E8")rn for(i = 7; i >= 0; i --)rn rn if ( i % 2 ) // 低4位所代表16进制表字符扩展为一个字节rn rn res[i] = (res[i/2] & 0x0F) + '0';rn if ( res[i] > '9' )rn rn res[i] = res[i] + 'A' - '0' - 10;rn rn rn else //高4位所代表16进制表字符扩展为一个字节rn rn res[i] = ((res[i/2] >> 4) & 0x0F) + '0';rn if ( res[i] > '9' )rn rn res[i] = res[i] + 'A' - '0' - 10;rn rn rn rnrnrn[/code]rnrnrn以上代码用java代码如何编写。。。。rnrn在此感谢大家了。。
C#语言为下,希望转成java代码,谢谢!
C#语言为下,希望转成java代码,谢谢!rnusing System.Security.Cryptography;rnusing System.Text;rn/// rn/// RSA加密rn/// rn/// 公钥rn/// rn/// RSA公钥加密后的数据rnpublic string RSAEncrypt(string xmlPublicKey, string m_strEncryptString)rnrnstring strEncry=””;rntryrnrnRSACryptoServiceProvider provider = new RSACryptoServiceProvider();rnprovider.FromXmlString(xmlPublicKey);rnbyte[] bytes = new UnicodeEncoding().GetBytes(m_strEncryptString);rnstrEncry = Convert.ToBase64String(provider.Encrypt(bytes, false));rnrncatch (Exception exception)rnrnthrow exception;rnrnreturn strEncry;rn
解决webservice的WSDL文件无法转成java代码
把wsdl文件中的引用另外一个wsdl文件删掉,并把另外一个wsdl文件中的内容从标签开始替换掉这段 因为myeclipse自带的这种生成webservice客户端无法识别引用的wsdl文件
谁能帮我这一小段C#转成Java代码
[code=C#]using System;rnusing System.Text;rnusing System.IO;rnusing System.Net;rnrnrnnamespace 信息提取rnrn public partial class class1rn rn string GetWebContent(string Url)rn rn string strResult = "";rn tryrn rn WebRequest request = WebRequest.Create(Url);rn request.Timeout = 30000;rn request.Headers.Set("Pragma", "no-cache");rn WebResponse response = request.GetResponse();rn Stream streamReceive = response.GetResponseStream();rn StreamReader streamReader = new StreamReader(streamReceive, Encoding.GetEncoding("GB2312"));rn strResult = streamReader.ReadToEnd();rn rn catchrn rn rn return strResult;rn rn rn[/code]
相关热词 c# 去空格去转义符 c#用户登录窗体代码 c# 流 c# linux 可视化 c# mvc 返回图片 c# 像素空间 c# 日期 最后一天 c#字典序排序 c# 截屏取色 c#中的哪些属于托管机制