以下是我的代码。请问大虾们问题出在哪????
时间戳:
public static String getTimeStamp() {
Calendar now = Calendar.getInstance();
int month=now.get(now.MONTH)+1;
int day=now.get(now.DATE);
int hour=now.get(now.HOUR);
int minute=now.get(now.MINUTE);
int second=now.get(now.SECOND);
Integer timeStamp=(month * 100000000 + day * 1000000 + hour * 10000 +
minute * 100 + second);
String tempStr=String.valueOf(timeStamp);
if(month<10){
tempStr="0"+timeStamp;
}
return tempStr;
}
模拟器返回 2说是连接过大,到了正式环境就变72了
认证码:
public static byte[] getAuthCode(String clientid,String pwd,String timestamp) throws NoSuchAlgorithmException{
int len=clientid.length()+key.length()+17;
byte tmpByte[] = new byte[len];
int tmp = 0;
System.arraycopy(clientid.getBytes(), 0, tmpByte, 0, clientid.length());
tmp = clientid.length() + 7;
System.arraycopy(key.getBytes(), 0, tmpByte, tmp, pwd.length());
tmp += pwd.length();
System.arraycopy(timestamp.getBytes(), 0, tmpByte, tmp, 10);
return MD5(tmpByte);
}
private static byte[] MD5(byte[] sourece) throws NoSuchAlgorithmException{
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(sourece);
return md5.digest();
}
------解决方案--------------------------------------------------------
Integer timeStamp=(month * 100000000 + day * 1000000 + hour * 10000 +
minute * 100 + second);
这里明显错误撒 Integer 能装下吗,还有就是month * 100000000是月的毫秒吗,多想一下