List of usage examples for org.joda.time DateTimeZone forID
@FromString public static DateTimeZone forID(String id)
From source file:eu.itesla_project.entsoe.util.EntsoeFileName.java
License:Mozilla Public License
public static EntsoeFileName parse(String str) { DateTime date = DateTime.now();/* w ww . jav a2 s. c om*/ int forecastDistance = 0; EntsoeGeographicalCode geographicalCode = null; Matcher m = DATE_REGEX.matcher(str); if (m.matches()) { // time zone is Europe/Paris int year = Integer.parseInt(m.group(1)); int month = Integer.parseInt(m.group(2)); int dayOfMonth = Integer.parseInt(m.group(3)); int hourOfDay = Integer.parseInt(m.group(4)); int minute = Integer.parseInt(m.group(5)); date = new DateTime(year, month, dayOfMonth, hourOfDay, minute, DateTimeZone.forID("Europe/Paris")); // extract horizon and forecast distance if (str.contains("FO")) { forecastDistance = 60 * (6 + hourOfDay) + minute; // DACF generated at 18:00 one day ahead7 } else if (str.contains("SN")) { forecastDistance = 0; } } if (str.length() >= 19) { geographicalCode = EntsoeGeographicalCode.valueOf(str.substring(18, 20)); } return new EntsoeFileName(date, forecastDistance, geographicalCode); }
From source file:eu.itesla_project.ucte.util.UcteFileName.java
License:Mozilla Public License
public static UcteFileName parse(String str) { DateTime date = DateTime.now();/* www . j av a 2 s. c o m*/ int forecastDistance = 0; UcteGeographicalCode geographicalCode = null; Matcher m = DATE_REGEX.matcher(str); if (m.matches()) { // time zone is Europe/Paris int year = Integer.parseInt(m.group(1)); int month = Integer.parseInt(m.group(2)); int dayOfMonth = Integer.parseInt(m.group(3)); int hourOfDay = Integer.parseInt(m.group(4)); int minute = Integer.parseInt(m.group(5)); date = new DateTime(year, month, dayOfMonth, hourOfDay, minute, DateTimeZone.forID("Europe/Paris")); // extract horizon and forecast distance if (str.contains("FO")) { forecastDistance = 60 * (6 + hourOfDay) + minute; // DACF generated at 18:00 one day ahead7 } else if (str.contains("SN")) { forecastDistance = 0; } } if (str.length() >= 19) { geographicalCode = UcteGeographicalCode.valueOf(str.substring(18, 20)); } return new UcteFileName(date, forecastDistance, geographicalCode); }
From source file:externalTools.TimeZoneTable.java
License:Apache License
public static void main(String[] args) throws Exception { Set idSet = DateTimeZone.getAvailableIDs(); ZoneData[] zones = new ZoneData[idSet.size()]; {//from w w w . j ava 2 s .co m Iterator it = idSet.iterator(); int i = 0; while (it.hasNext()) { String id = (String) it.next(); zones[i++] = new ZoneData(id, DateTimeZone.forID(id)); } Arrays.sort(zones); } PrintStream out = System.out; out.println("<table>"); out.println("<tr>" + "<th align=\"left\">Standard Offset</th>" + "<th align=\"left\">Canonical ID</th>" + "<th align=\"left\">Aliases</th>" + "</tr>"); ZoneData canonical = null; List aliases = new ArrayList(); for (int i = 0; i < zones.length; i++) { ZoneData zone = zones[i]; if (!zone.isCanonical()) { aliases.add(zone); continue; } if (canonical != null) { printRow(out, canonical, aliases); } canonical = zone; aliases.clear(); } if (canonical != null) { printRow(out, canonical, aliases); } out.println("</table>"); }
From source file:fast.bats.europe.FastPitchMessage.java
License:Apache License
public DateTime getDateTime() { DateTimeZone timeZone = DateTimeZone.forID("Europe/London"); DateTime midnight = new DateTime(timeZone).toDateMidnight().toDateTime(); return midnight.plusMillis((int) getTimestamp()); }
From source file:fi.riista.integration.lupahallinta.HarvestReportListCSVResponse.java
public static String createFileName() { final String timestamp = DF_FILENAME.print(DateTime.now(DateTimeZone.forID("Europe/Helsinki"))); return timestamp + "-riista-harvest-export.csv"; }
From source file:fr.amap.commons.animation.Timeline.java
public static void main(String[] args) { DateTimeZone zone = DateTimeZone.forID("Europe/Paris"); Timeline timeline = new Timeline(new DateTime(2016, 10, 30, 0, 0, zone), new DateTime(2016, 10, 30, 23, 59, zone), 0.01); timeline.addTimelineListener(new TimelineAdapter() { @Override/* w w w. j a v a 2s . c om*/ public void onTimeChanged(DateTime time) { System.out.println(time.toString("HH:mm:ss")); } }); int nearestIndex = timeline.getNearestIndex(new DateTime(2016, 10, 30, 1, 2, zone)); timeline.start(); }
From source file:fr.ybonnel.crawler.LanyrdCrawler.java
License:Apache License
public List<Schedule> crawl() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { if (cachesSchedules != null) { return cachesSchedules; }/*from w ww .j a v a 2 s . c o m*/ Method starting = TestWatcher.class.getDeclaredMethod("starting", Description.class); starting.setAccessible(true); starting.invoke(this.lifecycle, Description.EMPTY); goTo("/"); List<Schedule> schedules = new ArrayList<>(); List<Speaker> allSpeakers = new ArrayList<>(); for (FluentWebElement scheduleItem : find("li.schedule-item")) { Schedule schedule = new Schedule(); schedule.setTitle(scheduleItem.find("h2 a").getText()); schedule.setUrl(scheduleItem.find("h2 a").getAttribute("href")); schedule.setDescription(scheduleItem.find("div.desc").getText()); String startDate = scheduleItem.find("span.dtstart span.value-title").getAttribute("title"); String endDate = scheduleItem.find("span.dtend span.value-title").getAttribute("title"); schedule.setBeginDate( new LocalDateTime(startDate.replace("+ZZ:ZZ", ""), DateTimeZone.forID("Europe/Paris")) .toDate()); schedule.setEndDate( new LocalDateTime(endDate.replace("+ZZ:ZZ", ""), DateTimeZone.forID("Europe/Paris")).toDate()); schedule.setRoom( scheduleItem.find("div.schedule-meta div p", 1).getText().split("\n")[1].split(",")[0]); schedules.add(schedule); } for (Schedule schedule : schedules) { goTo(schedule.getUrl()); for (FluentWebElement profileItem : find("div.primary div.mini-profile")) { Speaker speaker = new Speaker(); speaker.setAvatar(profileItem.find("div.avatar a img").getAttribute("src")); speaker.setName(profileItem.find("span.name a").getText()); speaker.setBio(profileItem.find("div.profile-longdesc p").getText()); schedule.getSpeakers().add(speaker); } } getDriver().quit(); cachesSchedules = schedules; return schedules; }
From source file:fr.ybonnel.services.ScoreJob.java
License:Apache License
@Override public void run() { logger.info("run"); try {//from ww w . j a v a2 s . c o m DateTime now = new DateTime(DateTimeZone.forID("Europe/Paris")); for (PlayerInfo playerInfo : playerService.leaderboard()) { if (playerInfo.getAverageScore() > 0) { ScoreWithHistory scoreWithHistory = MongoService.getDatastore() .find(ScoreWithHistory.class, "pseudo", playerInfo.getPseudo()).get(); if (scoreWithHistory == null) { scoreWithHistory = new ScoreWithHistory(); scoreWithHistory.setPseudo(playerInfo.getPseudo()); } scoreWithHistory.setPhoto(playerInfo.getPhoto()); scoreWithHistory.getScores().add(new Score(now.toDate(), playerInfo.getScore())); scoreWithHistory.getAverageScores().add(new Score(now.toDate(), playerInfo.getAverageScore())); scoreWithHistory.aggregateScores(now); MongoService.getDatastore().save(scoreWithHistory.prepareForDb()); } } // Clean negative of no playing players for (ScoreWithHistory scoreWithHistory : MongoService.getDatastore().find(ScoreWithHistory.class) .asList()) { if (scoreWithHistory.mustBeRemoved()) { MongoService.getDatastore().delete(scoreWithHistory.prepareForDb()); } } } catch (Exception exception) { exception.printStackTrace(); } }
From source file:gobblin.azkaban.AzkabanJobLauncher.java
License:Apache License
/** * Uses the properties {@link ConfigurationKeys#AZKABAN_EXECUTION_DAYS_LIST}, * {@link ConfigurationKeys#AZKABAN_EXECUTION_TIME_RANGE}, and * {@link TimeRangeChecker#isTimeInRange(List, String, String, DateTime)} to determine if the current job should * continue its execution based on the extra scheduled parameters defined in the config. * * @return true if this job should be launched, false otherwise. *//*from w ww .ja v a2 s .c o m*/ private boolean isCurrentTimeInRange() { Splitter splitter = Splitter.on(",").omitEmptyStrings().trimResults(); if (this.props.contains(ConfigurationKeys.AZKABAN_EXECUTION_DAYS_LIST) && this.props.contains(ConfigurationKeys.AZKABAN_EXECUTION_TIME_RANGE)) { List<String> executionTimeRange = splitter .splitToList(this.props.getProperty(ConfigurationKeys.AZKABAN_EXECUTION_TIME_RANGE)); List<String> executionDays = splitter .splitToList(this.props.getProperty(ConfigurationKeys.AZKABAN_EXECUTION_DAYS_LIST)); Preconditions.checkArgument(executionTimeRange.size() == 2, "The property " + ConfigurationKeys.AZKABAN_EXECUTION_DAYS_LIST + " should be a comma separated list of two entries"); return TimeRangeChecker.isTimeInRange(executionDays, executionTimeRange.get(0), executionTimeRange.get(1), new DateTime(DateTimeZone.forID(ConfigurationKeys.PST_TIMEZONE_NAME))); } return true; }
From source file:gobblin.compaction.dataset.DatasetHelper.java
License:Apache License
public Optional<DateTime> getEarliestLateFileModificationTime() { DateTimeZone timeZone = DateTimeZone.forID(this.dataset.jobProps().getProp(MRCompactor.COMPACTION_TIMEZONE, MRCompactor.DEFAULT_COMPACTION_TIMEZONE)); try {// w w w . ja v a 2s.co m long maxTimestamp = Long.MIN_VALUE; for (FileStatus status : FileListUtils.listFilesRecursively(this.fs, this.dataset.outputLatePath())) { maxTimestamp = Math.max(maxTimestamp, status.getModificationTime()); } return maxTimestamp == Long.MIN_VALUE ? Optional.<DateTime>absent() : Optional.of(new DateTime(maxTimestamp, timeZone)); } catch (Exception e) { logger.error("Failed to get earliest late file modification time"); return Optional.absent(); } }