Example usage for org.joda.time DateTime getDayOfMonth

List of usage examples for org.joda.time DateTime getDayOfMonth

Introduction

In this page you can find the example usage for org.joda.time DateTime getDayOfMonth.

Prototype

public int getDayOfMonth() 

Source Link

Document

Get the day of month field value.

Usage

From source file:com.google.cloud.dataflow.examples.opinionanalysis.IndexerPipelineUtils.java

License:Apache License

public static int getDateIdFromTimestamp(long millis) {
    int result;/*from ww w .j  a  v  a 2s.  c o 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.
 *//*from ww w.j  a va 2 s  .  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.gs.fw.common.mithra.attribute.calculator.arithmeticCalculator.DateDayOfMonthCalculator.java

License:Apache License

@Override
public int intValueOf(Object o) {
    Date date = this.attribute.valueOf(o);
    DateTime time = new DateTime(date);
    return time.getDayOfMonth();
}

From source file:com.gs.fw.common.mithra.attribute.calculator.arithmeticCalculator.TimestampDayOfMonthCalculator.java

License:Apache License

@Override
public int intValueOf(Object o) {
    Timestamp timestamp = this.attribute.valueOf(o);
    DateTime time = new DateTime(timestamp.getTime());
    return time.getDayOfMonth();
}

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());/*from   w  ww  .  j  a  v  a  2  s. c  om*/
    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./*from w  w  w . ja va 2  s. c o  m*/
 */
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());/*from ww  w .  jav a 2s .c om*/
}

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());// w  ww .j  av  a 2s  .  c  om
}

From source file:com.hmsinc.epicenter.webapp.chart.TimeSeriesChart.java

License:Open Source License

/**
 * @param period/*from w ww  .j  a  v a 2 s  .  co  m*/
 * @param date
 * @return
 */
private static org.jfree.data.time.RegularTimePeriod getEntryPeriod(final TimeSeriesPeriod period,
        final DateTime date) {

    final org.jfree.data.time.RegularTimePeriod ret;

    switch (period) {
    case DAY:
        ret = new Day(date.getDayOfMonth(), date.getMonthOfYear(), date.getYear());
        break;
    case HOUR:
        ret = new Hour(date.getHourOfDay(), date.getDayOfYear(), date.getMonthOfYear(), date.getYear());
        break;
    case MONTH:
        ret = new Month(date.getMonthOfYear(), date.getYear());
        break;
    case YEAR:
        ret = new Year(date.getYear());
        break;
    default:
        throw new UnsupportedOperationException("Unsupported period: " + period);
    }

    return ret;

}