Example usage for org.joda.time DateTime getYear

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

Introduction

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

Prototype

public int getYear() 

Source Link

Document

Get the year field value.

Usage

From source file:com.excilys.ebi.bank.web.controller.DefaultsController.java

License:Apache License

@RequestMapping("/private/bank/account/*/cards/*/operations.html")
public String displayCardOperationsWithDefaults() {

    DateTime now = bankService.getDefaultDateTime();

    return new StringBuilder().append("forward:year/").append(now.getYear()).append("/month/")
            .append(now.getMonthOfYear()).append("/operations.html").toString();
}

From source file:com.flipkart.foxtrot.core.querystore.impl.ElasticsearchUtils.java

License:Apache License

@VisibleForTesting
public static String[] getIndices(final String table, final ActionRequest request, final Interval interval) {
    DateTime start = interval.getStart().toLocalDate().toDateTimeAtStartOfDay();
    if (start.getYear() <= 1970) {
        logger.warn("Request of type {} running on all indices", request.getClass().getSimpleName());
        return new String[] { getIndices(table) };
    }//from   ww w.ja v a 2s  .  c o m
    List<String> indices = Lists.newArrayList();
    final DateTime end = interval.getEnd().plusDays(1).toLocalDate().toDateTimeAtStartOfDay();
    while (start.getMillis() < end.getMillis()) {
        final String index = getCurrentIndex(table, start.getMillis());
        indices.add(index);
        start = start.plusDays(1);
    }
    logger.info("Request of type {} on indices: {}", request.getClass().getSimpleName(), indices);
    return indices.toArray(new String[indices.size()]);
}

From source file:com.foundationdb.server.types.mcompat.mtypes.MDateAndTime.java

License:Open Source License

/** Convert millis to a date in the given timezone and then {@link #encodeDate(long, long, long)}. */
public static int encodeDate(long millis, String tz) {
    DateTime dt = new DateTime(millis, DateTimeZone.forID(tz));
    return encodeDate(dt.getYear(), dt.getMonthOfYear(), dt.getDayOfMonth());
}

From source file:com.foundationdb.server.types.mcompat.mtypes.MDateAndTime.java

License:Open Source License

/** Decode {@code encodedTimestamp} using the {@code tz} timezone. */
public static long[] decodeTimestamp(long encodedTimestamp, String tz) {
    DateTime dt = new DateTime(encodedTimestamp * 1000L, DateTimeZone.forID(tz));
    return new long[] { dt.getYear(), dt.getMonthOfYear(), dt.getDayOfMonth(), dt.getHourOfDay(),
            dt.getMinuteOfHour(), dt.getSecondOfMinute() };
}

From source file:com.getusroi.wms20.parcel.parcelservice.stamps.service.StampsRateServiceBuilder.java

/**
 * this is to get the currentDate in string format to process the current
 * date in Stamps append//from w ww.j  a v  a  2 s  .  c  o  m
 * 
 * @return string form of date ~(YYYY-MM-DD)
 */
private static String getCurrentDateString() {

    org.joda.time.DateTime dateTime_Utc = new DateTime(DateTimeZone.UTC);
    int monthUTC = dateTime_Utc.getMonthOfYear();
    String month;
    switch (monthUTC) {
    case 1:
        month = "01";
        break;
    case 2:
        month = "02";
        break;
    case 3:
        month = "03";
        break;
    case 4:
        month = "04";
        break;
    case 5:
        month = "05";
        break;
    case 6:
        month = "06";
        break;
    case 7:
        month = "07";
        break;
    case 8:
        month = "08";
        break;
    case 9:
        month = "09";
        break;
    default:
        month = Integer.toString(monthUTC);
        break;
    }
    String dateToString = dateTime_Utc.getYear() + "-" + month + "-" + dateTime_Utc.getDayOfMonth();
    return dateToString;
}

From source file:com.github.autermann.matlab.value.MatlabDateTime.java

License:Open Source License

public double[] toArray() {
    DateTime utc = time.toDateTime(DateTimeZone.UTC);
    return new double[] { (double) utc.getYear(), (double) utc.getMonthOfYear(), (double) utc.getDayOfMonth(),
            (double) utc.getHourOfDay(), (double) utc.getMinuteOfHour(),
            (double) utc.getSecondOfMinute() + (double) utc.getMillisOfSecond() / 1000, };

}

From source file:com.google.api.ads.adwords.awreporting.model.entities.dateranges.LastMonthDateRangeHandler.java

License:Open Source License

@Override
public DateTime retrieveDateStart(DateTime date) {
    DateTime minusMonth = date.minusMonths(1);
    return new DateTime(minusMonth.getYear(), minusMonth.getMonthOfYear(), 1, 12, 0);
}

From source file:com.google.api.ads.adwords.awreporting.model.entities.dateranges.LastMonthDateRangeHandler.java

License:Open Source License

@Override
public DateTime retrieveDateEnd(DateTime date) {
    DateTime sameDate = new DateTime(date.getYear(), date.getMonthOfYear(), 1, 12, 0);
    return sameDate.minusDays(1);
}

From source file:com.google.api.ads.adwords.awreporting.model.entities.dateranges.ThisMonthDateRangeHandler.java

License:Open Source License

@Override
public DateTime retrieveDateStart(DateTime date) {
    return new DateTime(date.getYear(), date.getMonthOfYear(), 1, 12, 0);
}

From source file:com.google.api.ads.adwords.awreporting.model.entities.dateranges.ThisMonthDateRangeHandler.java

License:Open Source License

@Override
public DateTime retrieveDateEnd(DateTime date) {
    DateTime plusMonth = date.plusMonths(1);
    plusMonth = new DateTime(plusMonth.getYear(), plusMonth.getMonthOfYear(), 1, 12, 0);
    return plusMonth.minusDays(1);
}