有人问我这个问题:
给定时间戳作为long值,在Java中编写实用程序函数以减少毫秒.例如,给定输入1274883865399(实际时间:20100526T14:24:25.399Z),函数将返回1274883865000(实际时间:2010-05-26T14:24:25.000Z)
我这样做了:
import java.text.*;
import java.util.*;
public class ClearMilliSeconds {
public static void main(String[] args) {
long yourmilliseconds = 1274883865399L;
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");
Calendar c = Calendar.getInstance();
Date resultdate = new Date(yourmilliseconds);
c.set(Calendar.MILLISECOND, 0);
resultdate.setTime(c.getTimeInMillis());
System.out.println(sdf.format(resultdate));
}
}
Run Code Online (Sandbox Code Playgroud)
但它没有给我正确的结果
我今天接受了一次采访,有人问我是如何搜索数组中的数字的,我说二元搜索,他问我一个有数千个对象(例如股票)的大数组如何搜索例如股票的价格,我再说二进制搜索,他说在应用二进制搜索之前,对数千个数组进行排序会花费很多时间.
你能和我一起去教我怎么解决这个问题吗?谢谢你的帮助表示赞赏.
学习Spring MVC和Hibernate.
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Customer {
Run Code Online (Sandbox Code Playgroud)
在@Entity行中存在错误:无法将实体解析为类型
我从spring-framework-2.5.6获得了罐子你能告诉我我在这里缺少什么吗?