How do I create the java date object without time

2020-02-02 01:26发布

I want to create a Date object without a TimeZone (eg : 2007-06-21). Is this possible?

When I use the following method it prints like Thu Jun 21 00:00:00 GMT 2007

SimpleDateFormat  sdf       = new SimpleDateFormat("yyyy-MM-dd");

TimeZone          timeZone  = TimeZone.getTimeZone("GMT");
timeZone.setDefault(timeZone);
sdf.setTimeZone(timeZone);

Date              pickUpDate = sdf.parse("2007-06-21");
System.out.println(pickUpDate);

7条回答
闹够了就滚
2楼-- · 2020-02-02 01:55
System.out.println("pickUpDate " + sdf.format(pickUpDate));

You can use the above code to get formatted Date as String

查看更多
登录 后发表回答