List of usage examples for org.joda.time DateTime getYear
public int getYear()
From source file:com.google.cloud.dataflow.examples.opinionanalysis.IndexerPipelineUtils.java
License:Apache License
public static int getDateIdFromTimestamp(long millis) { int result;// www. j a v a2s. co m DateTime dt = new DateTime(millis, DateTimeZone.UTC); int year = dt.getYear(); int month = dt.getMonthOfYear(); int day = dt.getDayOfMonth(); result = day + (100 * month) + (10000 * year); return result; }
From source file:com.google.cloud.dataflow.sdk.util.TimeUtil.java
License:Apache License
/** * Converts a {@link ReadableInstant} into a Dateflow API time value. *//* w w w .ja va 2s .c o m*/ public static String toCloudTime(ReadableInstant instant) { // Note that since Joda objects use millisecond resolution, we always // produce either no fractional seconds or fractional seconds with // millisecond resolution. // Translate the ReadableInstant to a DateTime with ISOChronology. DateTime time = new DateTime(instant); int millis = time.getMillisOfSecond(); if (millis == 0) { return String.format("%04d-%02d-%02dT%02d:%02d:%02dZ", time.getYear(), time.getMonthOfYear(), time.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute()); } else { return String.format("%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", time.getYear(), time.getMonthOfYear(), time.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), millis); } }
From source file:com.google.jenkins.plugins.cloudbackup.backup.BackupProcedure.java
License:Open Source License
private static String calculateBackupName(DateTime backupTime) { return String.format("backup-%d%02d%02d%02d%02d%02d", backupTime.getYear(), backupTime.getMonthOfYear(), backupTime.getDayOfMonth(), backupTime.getHourOfDay(), backupTime.getMinuteOfHour(), backupTime.getSecondOfMinute()); }
From source file:com.gote.downloader.kgs.KGSDownloader.java
License:Apache License
public List<Document> getPlayerArchive(String pPlayer, DateTime pStartDate, DateTime pEndDate) { stage = "Etape 2/3- Tlchargement"; List<Document> archivesPages = new ArrayList<Document>(); ArchivePageUrlBuilder archivePageUrlBuilder; ArchivePageManager archivePageManager = new ArchivePageManager(); // Found the maximum checkable year and month to avoid checking inexistant page (time lost and // more exception possibilities) int minEndMonth = 1; int minEndYear = pStartDate.getYear(); DateTime today = new DateTime(); if (pEndDate.getYear() > today.getYear()) { minEndMonth = today.getMonthOfYear(); minEndYear = today.getYear();//from w w w. j a v a 2 s . co m } else if (pEndDate.getYear() < today.getYear()) { minEndMonth = pEndDate.getMonthOfYear(); minEndYear = pEndDate.getYear(); } else { minEndMonth = pEndDate.getMonthOfYear() < today.getMonthOfYear() ? pEndDate.getMonthOfYear() : today.getMonthOfYear(); minEndYear = today.getYear(); } // For each year until the end year or the end of the current year for (int year = pStartDate.getYear(); year <= minEndYear; year++) { // Found intervals in order to avoid time lost and inexistant pages access int firstMonth = 1; int lastMonth = 13; if (year == pStartDate.getYear()) { firstMonth = pStartDate.getMonthOfYear(); } if (year == minEndYear) { lastMonth = minEndMonth; } // For each month for (int month = firstMonth; month <= lastMonth; month++) { archivePageUrlBuilder = new ArchivePageUrlBuilder(pPlayer, new Integer(year).toString(), new Integer(month).toString()); archivePageManager = new ArchivePageManager(archivePageUrlBuilder.getUrl()); Document doc = archivePageManager.getArchivePage(); if (doc != null) { archivesPages.add(doc); } // Wait for a amount of time, then KGS will not block the access try { Thread.sleep(WAITING_TIME); } catch (InterruptedException e) { e.printStackTrace(); } } } return archivesPages; }
From source file:com.gs.fw.common.mithra.attribute.calculator.arithmeticCalculator.DateYearCalculator.java
License:Apache License
@Override public int intValueOf(Object o) { Date date = this.attribute.valueOf(o); DateTime time = new DateTime(date); return time.getYear(); }
From source file:com.gs.fw.common.mithra.attribute.calculator.arithmeticCalculator.TimestampYearCalculator.java
License:Apache License
@Override public int intValueOf(Object o) { Timestamp timestamp = this.attribute.valueOf(o); DateTime time = new DateTime(timestamp.getTime()); return time.getYear(); }
From source file:com.gu.openplatform.contentapi.ApiUrlFactory.java
License:Apache License
private String generateUrlRepresentation(DateTime date) { StringBuilder dateBuilder = new StringBuilder(); dateBuilder.append(date.getYear()); dateBuilder.append("-"); dateBuilder.append(date.getMonthOfYear()); dateBuilder.append("-"); dateBuilder.append(date.getDayOfMonth()); return dateBuilder.toString(); }
From source file:com.hm.cal.date.GregorianCalendar.java
License:Apache License
/** * Constructs a Gregorian Calendar given a Joda DateTime. * * @param dt a Joda DateTime.// w w w.ja v a 2 s .c om */ public GregorianCalendar(DateTime dt) { this(dt.getYear(), dt.getMonthOfYear(), dt.getDayOfMonth()); }
From source file:com.hmsinc.epicenter.util.DateTimeUtils.java
License:Open Source License
public static DateTime toStartOfDay(final DateTime date) { return new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), 0, 0, 0, 0, date.getZone());/*ww w. j a v a 2s . com*/ }
From source file:com.hmsinc.epicenter.util.DateTimeUtils.java
License:Open Source License
public static DateTime toEndOfDay(final DateTime date) { return new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), 23, 59, 59, 999, date.getZone());/*from w w w .java 2s. c om*/ }