zhaolixin007 2017-04-18 15:17 采纳率: 0%
浏览 862
已结题

java 问题求教,急急急!

JAVA:

1、map 存取方法
2、取list所有元素方式
3、是否了解json对象,map怎么转换为jsonobject,java数组和list怎么转换成jsonarray,

下面这段代码的功能:

operAge: function (birth,nowdate){
var age;
var nowDateFormat = nowdate.replace(/-/g,"");
var birthFormat = birth.replace(/-/g,"");
var years = parseInt(nowDateFormat.substr(0,4),10);
var month = parseInt(nowDateFormat.substr(4,2),10);
var days = parseInt(nowDateFormat.substr(6,2),10);
var birthYear = parseInt(birthFormat.substr(0,4),10);
var birthMonth = parseInt(birthFormat.substr(4,2),10);
var birthDate = parseInt(birthFormat.substr(6,2),10);

if(month-birthMonth {
age = yeas- birthYear -1;
}
else if(month-birthMonth>0)
{
age = yeas- birthYear;
}
else
{if(days-birthDate>=0)
{age = years - birthYear;}
else
{age = years - birthYear-1;}

}
if (age<0) age = 0;
return age;
}

下面这段代码功能是什么?
publisc final static String TimeUnit_YEAR = "year";
publisc final static String TimeUnit_MONTH = "month";
publisc final static String TimeUnit_DAY = "day";

publisc static Date accountDate(Date givenDate,int amount,String unit)
{
Calendar c = Calendar.getInstance();
c.setTime(giveDate);
if(unit != null && unit.trime().equals(TimeUnit_DAY))
{c.add(Calendar.DATE,amount);
return c.getTime();}
else if(unit != null && unit.trime().equals(TimeUnit_MONTH))
{c.add(Calendar.MONTH,amount);
return c.getTime();}
else if(unit != null && unit.trime().equals(TimeUnit_YEAR))
{c.add(Calendar.YEAR,amount);
return c.getTime();}
else
{return givenDate;}

}

  • 写回答

5条回答 默认 最新

  • threenewbee 2017-04-18 15:41
    关注

    前三个问题google下就有。第四个代码,从字符串中解析生日,并且计算年龄。最后一个代码,给定日期、单位、增量,计算得到另一个日期。

    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)