List of usage examples for org.joda.time MutableDateTime setMonthOfYear
public void setMonthOfYear(final int monthOfYear)
From source file:org.gdg.frisbee.android.eventseries.EventListFragment.java
License:Apache License
private DateTime getMonthStart(int month) { MutableDateTime date = new MutableDateTime(); date.setDayOfMonth(1);//from w ww . j a v a2s.c o m date.setMillisOfDay(0); date.setMonthOfYear(month); return date.toDateTime(); }
From source file:org.gdg.frisbee.android.eventseries.EventListFragment.java
License:Apache License
private DateTime getMonthEnd(int month) { MutableDateTime date = MutableDateTime.now(); date.setMillisOfDay(0);//from w w w .j a v a2 s. co m date.setMonthOfYear(month); return date.toDateTime().dayOfMonth().withMaximumValue().millisOfDay().withMaximumValue(); }
From source file:org.talend.components.netsuite.avro.converter.XMLGregorianCalendarToDateTimeConverter.java
License:Open Source License
@Override public Object convertToAvro(XMLGregorianCalendar xts) { if (xts == null) { return null; }/*from w ww . j a va2 s . c om*/ MutableDateTime dateTime = new MutableDateTime(); try { dateTime.setYear(xts.getYear()); dateTime.setMonthOfYear(xts.getMonth()); dateTime.setDayOfMonth(xts.getDay()); dateTime.setHourOfDay(xts.getHour()); dateTime.setMinuteOfHour(xts.getMinute()); dateTime.setSecondOfMinute(xts.getSecond()); dateTime.setMillisOfSecond(xts.getMillisecond()); DateTimeZone tz = DateTimeZone.forOffsetMillis(xts.getTimezone() * 60000); if (tz != null) { dateTime.setZoneRetainFields(tz); } return Long.valueOf(dateTime.getMillis()); } catch (IllegalArgumentException e) { throw new ComponentException(e); } }
From source file:y.elf.DbReader.java
License:Open Source License
public static List<ElfValue> readOldCentralineFile(String filename, int defaultvalue, int fieldnn) { final String separatorDate = "/"; final String separatorTime = ":"; final int UNUSED = Integer.MIN_VALUE; List<ElfValue> list = new ArrayList<ElfValue>(); BufferedReader reader = null; try {/* w w w .j ava2s . c om*/ reader = new BufferedReader(new FileReader(filename)); String line; MutableDateTime lasttime = new MutableDateTime(0, 1, 1, 0, 0, 0, 0); final MutableDateTime invalidtime = new MutableDateTime(0, 1, 1, 0, 0, 0, 0); while ((line = reader.readLine()) != null) { if (line.isEmpty()) continue; try { boolean valid = true; final String[] parts = tokenize(line); int value = UNUSED; int maxvalue = 0; for (int i = 0; i < parts.length; i++) { if (parts[i].equals("*")) valid = false; else if (parts[i].contains(separatorDate)) { final String[] date = parts[i].split(separatorDate); lasttime.setDayOfMonth(Integer.parseInt(date[0])); lasttime.setMonthOfYear(Integer.parseInt(date[1])); lasttime.setYear(Integer.parseInt(date[2])); } else if (parts[i].contains(separatorTime)) { final String[] hour = parts[i].split(separatorTime); lasttime.setHourOfDay(Integer.parseInt(hour[0])); lasttime.setMinuteOfHour(Integer.parseInt(hour[1])); } else if (value == UNUSED) value = translateValue(parts[i], defaultvalue); else maxvalue = translateValue(parts[i], defaultvalue); } if (lasttime.equals(invalidtime)) // invalid line (header) continue; final DateTime currentdatetime = lasttime.toDateTime(); if (value > 0) { if (fieldnn == 2) list.add(new ElfValue(currentdatetime, maxvalue, value, valid)); else list.add(new ElfValue(currentdatetime, value, maxvalue, valid)); } else list.add(new ElfValue(currentdatetime, 0, 0, false)); } catch (Exception e) { continue; } // on error, skip line } } catch (Exception e) { // System.out.println(e.getMessage()); } finally { if (reader != null) try { reader.close(); } catch (IOException e) { } } return list; }