How do you convert 2 dates one in BST(Current date) and the other in GMT so that the can be compared date before and after methods?

前端 未结 2 843
天命终不由人
天命终不由人 2021-01-22 12:09

How do you convert 2 dates one in BST(Current date) and the other in GMT so that they can be compared using the calendar date before() and after() methods? I don\'t know if BS

2条回答
  •  一个人的身影
    2021-01-22 12:38

    What about:

    Calendar calBst = new GregorianCalander();
    calBst.setDate(date1);
    calBst.setTimezone(TimeZone.getTimeZone("BST");
    
    Calendar calGmt = new GregorianCalander();
    calGmt.setDate(date2);
    calGmt.setTimezone(TimeZone.getTimeZone("GMT");
    calBst.before(calGmt);
    

提交回复
热议问题