Java Code Examples for org.joda.time.DateTime#getYear()
The following examples show how to use
org.joda.time.DateTime#getYear() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: secure-data-service File: DateTimeUtil.java License: Apache License 2.0 | 6 votes |
/** * Determines if the 1st date is before or equal to the 2nd date (comparing only year, month, day). * * @param date1 1st date object. * @param date2 2nd date object. * @return true if date1 is before or equal to date2, false if date1 is after date2. */ public static boolean isLeftDateBeforeRightDate(DateTime date1, DateTime date2) { boolean less = false; if (date1.getYear() < date2.getYear()) { less = true; } else if (date1.getYear() == date2.getYear()) { if (date1.getMonthOfYear() < date2.getMonthOfYear()) { less = true; } else if (date1.getMonthOfYear() == date2.getMonthOfYear()) { if (date1.getDayOfMonth() <= date2.getDayOfMonth()) { less = true; } } } return less; }
Example 2
Source Project: CustomizableCalendar File: Calendar.java License: MIT License | 6 votes |
public Calendar(DateTime firstMonth, DateTime lastMonth) { this.firstMonth = firstMonth; this.firstDayOfWeek = java.util.Calendar.getInstance(Locale.getDefault()).getFirstDayOfWeek(); DateTime startMonth = firstMonth.plusMonths(1); int monthsBetweenCount = Months.monthsBetween(firstMonth, lastMonth).getMonths(); months = new ArrayList<>(); months.add(firstMonth); currentMonth = firstMonth; DateTime monthToAdd = new DateTime(startMonth.getYear(), startMonth.getMonthOfYear(), 1, 0, 0); for (int i = 0; i <= monthsBetweenCount; i++) { months.add(monthToAdd); monthToAdd = monthToAdd.plusMonths(1); } }
Example 3
Source Project: phoenix File: YearFunction.java License: Apache License 2.0 | 6 votes |
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { Expression expression = getChildExpression(); if (!expression.evaluate(tuple, ptr)) { return false; } if ( ptr.getLength() == 0) { return true; //means null } long dateTime = inputCodec.decodeLong(ptr, expression.getSortOrder()); DateTime dt = new DateTime(dateTime); int year = dt.getYear(); PDataType returnType = getDataType(); byte[] byteValue = new byte[returnType.getByteSize()]; returnType.getCodec().encodeInt(year, byteValue, 0); ptr.set(byteValue); return true; }
Example 4
Source Project: astor File: DateTimePerformance.java License: GNU General Public License v2.0 | 5 votes |
private void checkJISOGetYear() { int COUNT = COUNT_VERY_FAST; DateTime dt = new DateTime(); for (int i = 0; i < AVERAGE; i++) { start("JISO", "getYear"); for (int j = 0; j < COUNT; j++) { int val = dt.getYear(); if (val == 0) {System.out.println("Anti optimise");} } end(COUNT); } }
Example 5
Source Project: freehealth-connector File: ResponseObjectMapper.java License: GNU Affero General Public License v3.0 | 5 votes |
public RevokeTherapeuticLinkResponse mapXMLToRevokeTherapeuticLinkResponse(String xml) throws TechnicalConnectorException { be.fgov.ehealth.hubservices.core.v2.RevokeTherapeuticLinkResponse jaxbResponse = (be.fgov.ehealth.hubservices.core.v2.RevokeTherapeuticLinkResponse)this.generateJAXB(xml, be.fgov.ehealth.hubservices.core.v2.RevokeTherapeuticLinkResponse.class); ResponseType jaxbResponseType = jaxbResponse.getResponse(); DateTime date = jaxbResponseType.getDate(); DateTime time = jaxbResponseType.getTime(); DateTime dateTime = new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond()); RevokeTherapeuticLinkResponse response = new RevokeTherapeuticLinkResponse(dateTime, this.mapAuthor(jaxbResponseType.getAuthor()), jaxbResponseType.getId().getValue(), this.mapOriginalRevokeTherapeuticLinkRequest(jaxbResponseType.getRequest()), this.mapAcknowledge(jaxbResponse.getAcknowledge())); LOG.info("Output request object :" + response.toString()); return response; }
Example 6
Source Project: freehealth-connector File: ResponseObjectMapper.java License: GNU Affero General Public License v3.0 | 5 votes |
public GetTherapeuticLinkResponse mapXMLToGetTherapeuticLinkResponse(String xml) throws TechnicalConnectorException { be.fgov.ehealth.hubservices.core.v2.GetTherapeuticLinkResponse jaxbResponse = (be.fgov.ehealth.hubservices.core.v2.GetTherapeuticLinkResponse)this.generateJAXB(xml, be.fgov.ehealth.hubservices.core.v2.GetTherapeuticLinkResponse.class); ResponseType jaxbResponseType = jaxbResponse.getResponse(); DateTime date = jaxbResponseType.getDate(); DateTime time = jaxbResponseType.getTime(); DateTime dateTime = new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond()); GetTherapeuticLinkResponse response = new GetTherapeuticLinkResponse(dateTime, this.mapAuthor(jaxbResponseType.getAuthor()), jaxbResponseType.getId().getValue(), this.mapOriginalGetTherapeuticLinkRequest(jaxbResponseType.getRequest()), this.mapListOfTherapeuticLinks(jaxbResponse.getTherapeuticlinklist()), this.mapAcknowledge(jaxbResponse.getAcknowledge())); LOG.info("Output request object :" + response.toString()); return response; }
Example 7
Source Project: freehealth-connector File: ResponseObjectMapper.java License: GNU Affero General Public License v3.0 | 5 votes |
public RevokeTherapeuticLinkResponse mapXMLToRevokeTherapeuticLinkResponse(String xml) throws TechnicalConnectorException { be.fgov.ehealth.hubservices.core.v2.RevokeTherapeuticLinkResponse jaxbResponse = (be.fgov.ehealth.hubservices.core.v2.RevokeTherapeuticLinkResponse)this.generateJAXB(xml, be.fgov.ehealth.hubservices.core.v2.RevokeTherapeuticLinkResponse.class); ResponseType jaxbResponseType = jaxbResponse.getResponse(); DateTime date = jaxbResponseType.getDate(); DateTime time = jaxbResponseType.getTime(); DateTime dateTime = new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond()); RevokeTherapeuticLinkResponse response = new RevokeTherapeuticLinkResponse(dateTime, this.mapAuthor(jaxbResponseType.getAuthor()), jaxbResponseType.getId().getValue(), this.mapOriginalRevokeTherapeuticLinkRequest(jaxbResponseType.getRequest()), this.mapAcknowledge(jaxbResponse.getAcknowledge())); LOG.info("Output request object :" + response.toString()); return response; }
Example 8
Source Project: dataflow-opinion-analysis File: IndexerPipelineUtils.java License: Apache License 2.0 | 5 votes |
public static int getDateIdFromTimestamp(long millis) { int result; 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; }
Example 9
Source Project: freehealth-connector File: ResponseObjectMapper.java License: GNU Affero General Public License v3.0 | 5 votes |
public PutTherapeuticLinkResponse mapXMLToPutTherapeuticLinkResponse(String xml) throws TechnicalConnectorException { be.fgov.ehealth.hubservices.core.v2.PutTherapeuticLinkResponse jaxbResponse = (be.fgov.ehealth.hubservices.core.v2.PutTherapeuticLinkResponse)this.generateJAXB(xml, be.fgov.ehealth.hubservices.core.v2.PutTherapeuticLinkResponse.class); ResponseType jaxbResponseType = jaxbResponse.getResponse(); DateTime date = jaxbResponseType.getDate(); DateTime time = jaxbResponseType.getTime(); DateTime dateTime = new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond(), DateTimeZone.getDefault()); PutTherapeuticLinkResponse response = new PutTherapeuticLinkResponse(dateTime, this.mapAuthor(jaxbResponseType.getAuthor()), jaxbResponseType.getId().getValue(), this.mapOriginalPutTherapeuticLinkRequest(jaxbResponseType.getRequest()), this.mapAcknowledge(jaxbResponse.getAcknowledge())); LOG.info("Output request object :" + response.toString()); return response; }
Example 10
Source Project: freehealth-connector File: ResponseObjectMapper.java License: GNU Affero General Public License v3.0 | 4 votes |
private DateTime mapDateTime(DateTime date, DateTime time) { return new DateTime(date != null ? date.getYear() : 0, date != null ? date.getMonthOfYear() : 1, date != null ? date.getDayOfMonth() : 1, time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond(), DateTimeZone.getDefault()); }
Example 11
Source Project: voice-pitch-analyzer File: RecordingList.java License: GNU Affero General Public License v3.0 | 4 votes |
/** * get beginning as date time with time set to 00:00:00:00 * * @return */ public DateTime getBeginningAsDate() { DateTime beginning = new DateTime(this.beginning); return new DateTime(beginning.getYear(), beginning.getMonthOfYear(), beginning.getDayOfMonth(), 0, 0, 0, 0); }
Example 12
Source Project: ambiverse-nlu File: DateTimeUtils.java License: Apache License 2.0 | 4 votes |
public static long roundToMidnight(long timestamp) { DateTime dt = new DateTime(timestamp); DateTime midnight = new DateTime(dt.getYear(), dt.getMonthOfYear(), dt.getDayOfMonth(), 0, 0); return midnight.getMillis(); }
Example 13
Source Project: freehealth-connector File: ResponseObjectMapper.java License: GNU Affero General Public License v3.0 | 4 votes |
private TherapeuticLinkRequestType mapOriginalHasTherapeuticLinkRequest(RequestType request) { DateTime date = request.getDate(); DateTime time = request.getTime(); DateTime dateTime = new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond()); return new HasTherapeuticLinkRequest(dateTime, request.getId().getValue(), this.mapAuthor((AuthorType)request.getAuthor()), (TherapeuticLink)null); }
Example 14
Source Project: freehealth-connector File: ResponseObjectMapper.java License: GNU Affero General Public License v3.0 | 4 votes |
private TherapeuticLinkRequestType mapOriginalRevokeTherapeuticLinkRequest(RequestType request) { DateTime date = request.getDate(); DateTime time = request.getTime(); DateTime dateTime = new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond()); return new RevokeTherapeuticLinkRequest(dateTime, request.getId().getValue(), this.mapAuthor(request.getAuthor()), (TherapeuticLink)null, (Proof[])null); }
Example 15
Source Project: freehealth-connector File: ResponseObjectMapper.java License: GNU Affero General Public License v3.0 | 4 votes |
private TherapeuticLinkRequestType mapOriginalGetTherapeuticLinkRequest(RequestType request) { DateTime date = request.getDate(); DateTime time = request.getTime(); DateTime dateTime = new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond()); return new GetTherapeuticLinkRequest(dateTime, request.getId().getValue(), this.mapAuthor(request.getAuthor()), (TherapeuticLink)null, 999, (Proof[])null); }
Example 16
Source Project: freehealth-connector File: ResponseObjectMapper.java License: GNU Affero General Public License v3.0 | 4 votes |
private TherapeuticLinkRequestType mapOriginalRevokeTherapeuticLinkRequest(RequestType request) { DateTime date = request.getDate(); DateTime time = request.getTime(); DateTime dateTime = new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond()); return new RevokeTherapeuticLinkRequest(dateTime, request.getId().getValue(), this.mapAuthor(request), (TherapeuticLink)null, (Proof[])null); }
Example 17
Source Project: Rhombus File: ShardingStrategyMonthly.java License: MIT License | 4 votes |
public long getShardKey(long timestamp){ DateTime d = new DateTime(timestamp, DateTimeZone.UTC); long year = (long)d.getYear(); long month = (long)d.getMonthOfYear(); return this.offset + ((year - START_YEAR)*12)+month; }
Example 18
Source Project: freehealth-connector File: ResponseObjectMapper.java License: GNU Affero General Public License v3.0 | 4 votes |
private DateTime mapDateTime(DateTime date, DateTime time) { return new DateTime(date != null ? date.getYear() : 0, date != null ? date.getMonthOfYear() : 1, date != null ? date.getDayOfMonth() : 1, time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond(), DateTimeZone.getDefault()); }
Example 19
Source Project: cloudhopper-commons File: DateTimeUtil.java License: Apache License 2.0 | 3 votes |
/** * Null-safe method that returns a new instance of a DateTime object rounded * downwards to the nearest second. The time zone of the returned DateTime * instance will be the same as the argument. Similar to a floor() function * on a float.<br> * Examples: * <ul> * <li>null -> null * <li>"2009-06-24 13:24:51.476 -8:00" -> "2009-06-24 13:24:51.000 -8:00" * </ul> * @param value The DateTime value to round downward * @return Null if the argument is null or a new instance of the DateTime * value rounded downwards to the nearest second. */ public static DateTime floorToSecond(DateTime value) { if (value == null) { return null; } return new DateTime(value.getYear(), value.getMonthOfYear(), value.getDayOfMonth(), value.getHourOfDay(), value.getMinuteOfHour(), value.getSecondOfMinute(), 0, value.getZone()); }
Example 20
Source Project: Mycat2 File: DateUtil.java License: GNU General Public License v3.0 | 2 votes |
/** * 获取date对象年份 * @param date * @return */ public static int getYear(Date date) { DateTime dt = new DateTime(date); return dt.getYear(); }