List of usage examples for org.joda.time DateTimeZone UTC
DateTimeZone UTC
To view the source code for org.joda.time DateTimeZone UTC.
Click Source Link
From source file:com.google.jenkins.plugins.persistentmaster.backup.BackupProcedure.java
License:Open Source License
/** * Performs a backup employing the extension point implementations provided * in the constructor./*from w ww . ja va 2s . c o m*/ * * @return the date and time the backup was taken. * @throws IOException if backup creation fails. */ public DateTime performBackup() throws IOException { logger.fine("Start creating backup"); final DateTime backupTime = new DateTime(DateTimeZone.UTC); // This is a no-op if the scratch directory already exists. if (tempDir != null) { Files.createDirectories(tempDir); } final Path tempDirectory = tempDir == null ? Files.createTempDirectory(TMP_DIR_PREFIX) : Files.createTempDirectory(tempDir, TMP_DIR_PREFIX); final String backupVolumeName = calculateBackupName(backupTime) + (backupNameSuffix != null ? backupNameSuffix : "") + "." + volume.getFileExtension(); logger.fine("Using temporary directory: " + tempDirectory); final Path volumePath = tempDirectory.resolve(Paths.get(backupVolumeName)); try { logger.fine("Creating backup volume"); int fileCount; try (Volume.Creator creator = volume.createNew(volumePath)) { scope.addFiles(jenkinsHome, creator); fileCount = creator.getFileCount(); } // auto-close creator if (fileCount > 0) { logger.fine("Storing backup volume"); storage.storeFile(volumePath, backupVolumeName); logger.fine("Updating last backup reference"); storage.updateLastBackup(Arrays.asList(backupVolumeName)); logger.fine("Apply backup history policy"); backupHistory.processHistoricBackups(storage, backupVolumeName); } else { logger.fine("Volume is empty, will skip storing backup"); } } finally { // cleanup after ourselves try { logger.fine("Deleting local backup volume"); Files.deleteIfExists(volumePath); logger.fine("Deleting temp directory"); Files.deleteIfExists(tempDirectory); } catch (IOException e) { // be silent about cleanup errors, only log them logger.log(Level.FINE, "IOException while performing cleanup", e); } } logger.fine("Finished creating backup"); return backupTime; }
From source file:com.google.location.lbs.gnss.gps.pseudorange.GpsTime.java
License:Apache License
/** * Creates a GPS time based upon the current time. */ public static GpsTime now() { return fromUtc(DateTime.now(DateTimeZone.UTC)); }
From source file:com.google.location.lbs.gnss.gps.pseudorange.GpsTime.java
License:Apache License
/** * @return Day of year in GPS time (GMT time) *//* w w w. j av a 2 s . com*/ public static int getCurrentDayOfYear() { DateTime current = DateTime.now(DateTimeZone.UTC); // Since current is derived from UTC time, we need to add leap second here. long gpsTimeMillis = current.getMillis() + getLeapSecond(current); DateTime gpsCurrent = new DateTime(gpsTimeMillis, UTC_ZONE); return gpsCurrent.getDayOfYear(); }
From source file:com.google.samples.apps.abelana.AbelanaThings.java
License:Open Source License
public static String getImage(String name) { final String Bucket = "abelana"; DateTime soon = DateTime.now(DateTimeZone.UTC).plusMinutes(20); long expires = soon.getMillis() / 1000; String stringToSign = "GET\n\n\n" + expires + "\n" + "/" + Bucket + "/" + name + ".webp"; String uri = "https://storage.googleapis.com/abelana/" + name + ".webp" + "?GoogleAccessId=" + credential.getServiceAccountId() + "&Expires=" + expires + "&Signature=" + Uri.encode(signData(stringToSign)); return uri;//from www .j ava 2s. co m }
From source file:com.google.sampling.experiential.server.DSQueryBuilder.java
License:Open Source License
private DateTime newDateTimeFromString(String firstDate, DateTimeZone jodaTimeZone) { DateTime parsedTime = jodaFormatter.withZone(jodaTimeZone).parseDateTime(firstDate); return parsedTime.withZone(DateTimeZone.UTC); }
From source file:com.google.sampling.experiential.server.DSQueryBuilder.java
License:Open Source License
private static Interval getNextWeek(DateTimeZone clientTimeZone) { DateTime dayNextWeek = new DateTime(clientTimeZone).plusDays(7).withZone(DateTimeZone.UTC); return getWeekEnclosing(dayNextWeek); }
From source file:com.google.sampling.experiential.server.DSQueryBuilder.java
License:Open Source License
private static DateTime getDayLastWeek(DateTimeZone clientTimeZone) { return new DateTime(clientTimeZone).minusDays(7).withZone(DateTimeZone.UTC); }
From source file:com.google.sampling.experiential.server.JDOQueryBuilder.java
License:Open Source License
private DateTime newDateTimeFromDateString(String firstDate, DateTimeZone jodaTimeZone) { DateTime parsedTime = jodaDateFormatter.withZone(jodaTimeZone).parseDateTime(firstDate); return parsedTime.withZone(DateTimeZone.UTC); }
From source file:com.google.sampling.experiential.server.JDOQueryBuilder.java
License:Open Source License
private DateTime newDateTimeFromDateTimeString(String firstDate, DateTimeZone jodaTimeZone) { DateTime parsedTime = jodaDateTimeFormatter.parseDateTime(firstDate); return parsedTime.withZone(DateTimeZone.UTC); }
From source file:com.google.sites.liberation.renderers.RendererUtils.java
License:Apache License
/** * Creates a new hAtom "updated" element for the given entry. *//* w w w.j a va2 s. co m*/ static XmlElement getUpdatedElement(BaseContentEntry<?> entry) { checkNotNull(entry); XmlElement element = new XmlElement("abbr"); element.setAttribute("class", "updated"); element.setAttribute("title", entry.getUpdated().toString()); DateTime jodaTime = new DateTime(entry.getUpdated().getValue(), DateTimeZone.UTC); element.addText(jodaTime.toString(formatter)); return element; }