List of usage examples for org.joda.time DateTime monthOfYear
public Property monthOfYear()
From source file:com.squarespace.template.plugins.PluginDateUtils.java
License:Apache License
private static void formatAggregate(DateTimeAggregate type, Locale locale, DateTime date, StringBuilder buf) { switch (type) { case FULL://from w w w . j a va2 s. co m buf.append(date.dayOfWeek().getAsShortText(locale)); buf.append(' '); leftPad(date.dayOfMonth().get(), '0', 2, buf); buf.append(' '); buf.append(date.monthOfYear().getAsShortText(locale)); buf.append(' '); buf.append(date.year().get()); buf.append(' '); leftPad(date.get(DateTimeFieldType.clockhourOfHalfday()), '0', 2, buf); buf.append(':'); leftPad(date.minuteOfHour().get(), '0', 2, buf); buf.append(':'); leftPad(date.secondOfMinute().get(), '0', 2, buf); buf.append(' '); buf.append(date.get(DateTimeFieldType.halfdayOfDay()) == 0 ? "AM" : "PM"); buf.append(' '); buf.append(date.getZone().getNameKey(date.getMillis())); break; case H240_M0: leftPad(date.get(DateTimeFieldType.clockhourOfDay()), '0', 2, buf); buf.append(':'); leftPad(date.minuteOfHour().get(), '0', 2, buf); break; case HHMMSSP: leftPad(date.get(DateTimeFieldType.hourOfHalfday()), '0', 2, buf); buf.append(':'); leftPad(date.getMinuteOfHour(), '0', 2, buf); buf.append(':'); leftPad(date.getSecondOfMinute(), '0', 2, buf); buf.append(' '); buf.append(date.get(DateTimeFieldType.halfdayOfDay()) == 0 ? "AM" : "PM"); break; case MMDDYY: leftPad(date.getMonthOfYear(), '0', 2, buf); buf.append('/'); leftPad(date.dayOfMonth().get(), '0', 2, buf); buf.append('/'); leftPad(date.yearOfCentury().get(), '0', 2, buf); break; case MMDDYYYY: leftPad(date.getMonthOfYear(), '0', 2, buf); buf.append('/'); leftPad(date.dayOfMonth().get(), '0', 2, buf); buf.append('/'); buf.append(date.getYear()); break; case YYYYMMDD: buf.append(date.year().get()); buf.append('-'); leftPad(date.monthOfYear().get(), '0', 2, buf); buf.append('-'); leftPad(date.dayOfMonth().get(), '0', 2, buf); break; default: break; } }
From source file:com.tech.auju.display.Gudang.java
private void generate() { // int d1 = (int) spDay1.getValue(); // int d2 = (int) spDay2.getValue(); // int m1 = cbMonth1.getSelectedIndex() + 1; // int m2 = cbMonth2.getSelectedIndex() + 1; // //1900 // int y1 = (int) spYear1.getValue(); // int y2 = (int) spYear2.getValue(); DateTime dt = new DateTime(); int y = dt.getYear() - 1900; int m = dt.monthOfYear().get() - 1; int d = dt.dayOfMonth().get(); Date date1 = new Date(y, m, d); Date date2 = new Date(y, m, d); try {//from www. j a v a2s . c o m new DocumentMaker().printArsip(date1, date2); } catch (FileNotFoundException ex) { Logger.getLogger(DocGenerator.class.getName()).log(Level.SEVERE, null, ex); } catch (JRException ex) { Logger.getLogger(DocGenerator.class.getName()).log(Level.SEVERE, null, ex); } System.out.println("1. " + date1.getDay() + date1.getMonth() + date1.getYear()); // System.out.println("2. " + d2 + m2 + y2); }
From source file:com.thinkbiganalytics.ingest.GetTableDataSupport.java
License:Apache License
protected static Date maxAllowableDateFromUnit(Date fromDate, UnitSizes unit) { DateTime jodaDate = new DateTime(fromDate); switch (unit) { case HOUR:// ww w. j a v a 2s.c om return jodaDate.hourOfDay().roundFloorCopy().toDate(); case DAY: return jodaDate.withHourOfDay(0).hourOfDay().roundFloorCopy().toDate(); case WEEK: return jodaDate.weekOfWeekyear().roundFloorCopy().toDate(); case MONTH: return jodaDate.monthOfYear().roundFloorCopy().toDate(); case YEAR: return jodaDate.withMonthOfYear(1).withDayOfMonth(1).withHourOfDay(0).hourOfDay().roundFloorCopy() .toDate(); } return fromDate; }
From source file:com.tmathmeyer.sentinel.models.data.Commitment.java
License:Open Source License
@Override public String getFormattedDateRange() { DateTime s = new DateTime(this.duedate); StringBuilder timeFormat = new StringBuilder().append(s.monthOfYear().getAsShortText()).append(", ") .append(Months.getDescriptiveNumber(s.getDayOfMonth())); return timeFormat.toString(); }
From source file:com.tmathmeyer.sentinel.models.data.Event.java
License:Open Source License
@Override public String getFormattedDateRange() { if (this.isMultiDayEvent()) { DateTime s = new DateTime(this.start); DateTime e = new DateTime(this.end); StringBuilder timeFormat = new StringBuilder().append(s.monthOfYear().getAsShortText()).append(", ") .append(Months.getDescriptiveNumber(s.getDayOfMonth())).append(" - ") .append(e.monthOfYear().getAsShortText()).append(", ") .append(Months.getDescriptiveNumber(e.getDayOfMonth())); return timeFormat.toString(); } else {//from ww w . j a va 2 s . c o m DateTime s = new DateTime(this.start); StringBuilder timeFormat = new StringBuilder().append(s.monthOfYear().getAsShortText()).append(", ") .append(Months.getDescriptiveNumber(s.getDayOfMonth())); return timeFormat.toString(); } }
From source file:com.yahoo.bard.webservice.util.DateTimeUtils.java
License:Apache License
/** * Round the date time back to the beginning of the nearest (inclusive) month of January, April, July, October. * * @param from the date being rounded/* w ww . j a v a 2 s .c o m*/ * * @return The nearest previous start of month for one of the three quarter months */ public static DateTime quarterlyRound(DateTime from) { DateTime.Property property = from.monthOfYear(); // Shift the month from a one to a zero basis (Jan == 0), then adjust backwards to one of the months that are // an integer multiple of three months from the start of the year, then round to the start of that month. return property.addToCopy(-1 * ((property.get() - 1) % 3)).monthOfYear().roundFloorCopy(); }
From source file:com.zaradai.kunzite.trader.services.md.eod.download.yahoo.YahooQuoteUrlFormatter.java
License:Apache License
@Override public String getUrl(String symbol, DateTime from, DateTime until) { Preconditions.checkArgument(!Strings.isNullOrEmpty(symbol)); Preconditions.checkNotNull(from);//ww w .java 2s . c om Preconditions.checkNotNull(until); Preconditions.checkArgument(from.isBefore(until)); StringBuilder sb = new StringBuilder(PREFIX_TAG); sb.append(SYMBOL_TAG); sb.append(symbol); sb.append(FROM_MONTH_TAG); sb.append(from.monthOfYear().get() - 1); sb.append(FROM_DAY_TAG); sb.append(from.dayOfMonth().get()); sb.append(FROM_YEAR_TAG); sb.append(from.year().get()); sb.append(TO_MONTH_TAG); sb.append(until.monthOfYear().get() - 1); sb.append(TO_DAY_TAG); sb.append(until.dayOfMonth().get()); sb.append(TO_YEAR_TAG); sb.append(until.year().get()); sb.append(POSTFIX_TAG); return sb.toString(); }
From source file:edu.nyu.vida.data_polygamy.utils.FrameworkUtils.java
License:BSD License
public static String getTemporalStr(int temporalResolution, int time) { DateTime dt = new DateTime(((long) time) * 1000, DateTimeZone.UTC); String temporal = ""; switch (temporalResolution) { case HOUR:/*from w w w . j a va2s . com*/ temporal = dt.year().getAsString() + "-" + dt.monthOfYear().getAsString() + "-" + dt.dayOfMonth().getAsString() + "-" + dt.hourOfDay().getAsString(); break; case DAY: temporal = dt.year().getAsString() + "-" + dt.monthOfYear().getAsString() + "-" + dt.dayOfMonth().getAsString(); break; case WEEK: temporal = dt.weekyear().getAsString() + "-" + dt.weekOfWeekyear().getAsString(); break; case MONTH: temporal = dt.year().getAsString() + "-" + dt.monthOfYear().getAsString(); break; case YEAR: temporal = dt.year().getAsString(); break; default: temporal = null; break; } return temporal; }
From source file:edu.nyu.vida.data_polygamy.utils.FrameworkUtils.java
License:BSD License
public static String getTemporalStr(int temporalResolution, DateTime dt) { String temporal = ""; switch (temporalResolution) { case HOUR://from ww w .j av a2 s .co m temporal = dt.year().getAsString() + "-" + dt.monthOfYear().getAsString() + "-" + dt.dayOfMonth().getAsString() + "-" + dt.hourOfDay().getAsString(); break; case DAY: temporal = dt.year().getAsString() + "-" + dt.monthOfYear().getAsString() + "-" + dt.dayOfMonth().getAsString(); break; case WEEK: temporal = dt.weekyear().getAsString() + "-" + dt.weekOfWeekyear().getAsString(); break; case MONTH: temporal = dt.year().getAsString() + "-" + dt.monthOfYear().getAsString(); break; case YEAR: temporal = dt.year().getAsString(); break; default: temporal = null; break; } return temporal; }
From source file:edu.nyu.vida.data_polygamy.utils.FrameworkUtils.java
License:BSD License
public static int getTime(int temporalResolution, String[] input, int tempPosition) { String temporal = ""; String format = ""; long time = 0L; try {/* www . j a va2 s .c o m*/ time = ((long) Double.parseDouble(input[tempPosition])) * 1000; } catch (Exception e) { return -1; } if (time < 0) return -1; DateTime dt = new DateTime(time, DateTimeZone.UTC); switch (temporalResolution) { case HOUR: temporal = dt.year().getAsString() + "-" + dt.monthOfYear().getAsString() + "-" + dt.dayOfMonth().getAsString() + "-" + dt.hourOfDay().getAsString(); format = "yyyy-MM-dd-HH z"; break; case DAY: temporal = dt.year().getAsString() + "-" + dt.monthOfYear().getAsString() + "-" + dt.dayOfMonth().getAsString(); format = "yyyy-MM-dd z"; break; case WEEK: temporal = dt.weekyear().getAsString() + "-" + dt.weekOfWeekyear().getAsString(); format = "xxxx-ww z"; break; case MONTH: temporal = dt.year().getAsString() + "-" + dt.monthOfYear().getAsString(); format = "yyyy-MM z"; break; case YEAR: temporal = dt.year().getAsString(); format = "yyyy z"; break; default: temporal = null; format = ""; break; } if (temporal == null) return -1; DateTimeFormatter formatter = DateTimeFormat.forPattern(format); return (int) (formatter.parseDateTime(temporal + " UTC").getMillis() / 1000); }