我想根据我们当地的时间获取国家

i want to fetch country based on our local timing

enter image description here我有这么多国家和他们自己的时间安排。如果我们的本地时间和国家时间相同,则应显示与所有国家相关的时间。 谁能帮我写一段代码和上传国家时间 Excel sheet。 先谢谢了。enter image description here

public void countryBased() {
    LocalDateTime dateTime = LocalDateTime.parse(LocalDateTime.now().toString());
    TimeZone gmtTime=TimeZone.getTimeZone("GMT"+00);
    System.out.println("gmtTime new-->" + gmtTime);

    System.out.println("dateTime-->" + dateTime);
    /*
     * SchedulerRunTimes schedulerRunTime =
     * SchedulerRunTimesLocalServiceUtil
     * .createSchedulerRunTimes(CounterLocalServiceUtil.increment());
     */
    List<SchedulerRunTimes> schedulerRunTime = SchedulerRunTimesLocalServiceUtil.getSchedulerRunTimeses(-1, -1);
    /*
     * schedulerRunTime.setLOCAL_STANDARD_TIME(String.valueOf(dateTime.
     * getHour() * 100));
     */
    for (SchedulerRunTimes schedulerRunTimes : schedulerRunTime) {
        String GMTRunTime = schedulerRunTimes.getGMTRunTime();
        System.out.println(GMTRunTime);
        String datetimes = (String.valueOf(dateTime.getHour()+00));
        /*if (gmtTime.equals(GMTRunTime)) {
            trigger(schedulerRunTimes);
        } else {
            System.out.println("time Mismatch");
        }*/
    }
}

private void trigger(SchedulerRunTimes runTimes) {
    _log.info(runTimes.getCountryName() + " is triggered.");
    _log.info(runTimes.getCountryCode() + " is triggered.");

}

}

我找到了解决方案。

   try {
        LocalDateTime dateTime = LocalDateTime.parse(LocalDateTime.now().toString());

        String GMTTiming = String.valueOf(dateTime.getHour() * 100);

        _log.info("GMT Time for Country-->" + GMTTiming);

        List<SchedulerRunTimes> schedulerRunTime = SchedulerRunTimesLocalServiceUtil.getSchedulerRunTimeses(-1, -1);

        for (SchedulerRunTimes schedulerRunTimes : schedulerRunTime) {
            String GMTRunTime = schedulerRunTimes.getGMTRunTime();
            _log.info("GMTRunTime-->" + GMTRunTime);

            _log.info("Compairing GMT Timing --------------->"
                    + GMTTiming.trim().equalsIgnoreCase(GMTRunTime.trim()));

            if (GMTTiming.trim().equalsIgnoreCase(GMTRunTime.trim())) {

                PurchasePrice.triggerCountry(schedulerRunTimes);
            } else {

                _log.info("Time is Different and Country Not Found");
            }
        }
        throw new CountryNotFoundException("Time is Different and Country Not Found");
    } catch (CountryNotFoundException e) {

        e.printStackTrace();
    }