我的代码:使用日期,而不是时间戳
Calendar calendar = DateProvider.getCalendarInstance(TimeZone.getTimeZone("GMT"));
calendar.setTime(date);
calendar.set(Calendar.YEAR, 1970);
calendar.set(Calendar.MONTH, Calendar.JANUARY);
calendar.set(Calendar.DATE, 1);
date = calendar.getTime();
Timestamp epochTimeStamp = new Timestamp(date.getTime());
我想消除在这种情况下使用时间戳,如何能实现与epochTimeStamp这里同样的事情,而无需使用的java.sql.Timestamp?我需要的格式与我使用Timestamp时相同。
如果你正在谈论写日期的'String'表示的格式,你应该使用'SimpleDateFormat'来代替。 –
你在做什么与时间戳? – jalynn2
当你说你“需要格式相同”时,我们不知道你的意思。你能澄清一下吗? – pamphlet