List of usage examples for java.util Calendar roll
public void roll(int field, int amount)
From source file:Main.java
/** * Get last month end day/* w ww .j a v a 2 s. c o m*/ */ public static int getLastMonthEndDay() { Calendar lastDate = Calendar.getInstance(); lastDate.add(Calendar.MONTH, -1); lastDate.set(Calendar.DATE, 1); lastDate.roll(Calendar.DATE, -1); return lastDate.getActualMaximum(Calendar.DAY_OF_MONTH); }
From source file:Main.java
/** * Get next month end day// w w w.j a v a2 s . com * * @return */ public static int getNextMonthEndDay() { Calendar lastDate = Calendar.getInstance(); lastDate.add(Calendar.MONTH, 1); lastDate.set(Calendar.DATE, 1); lastDate.roll(Calendar.DATE, -1); return lastDate.getActualMaximum(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static int getDaysByYearMonth(int year, int month) { Calendar a = Calendar.getInstance(); a.set(Calendar.YEAR, year);/* w w w . j a va 2 s. c o m*/ a.set(Calendar.MONTH, month - 1); a.set(Calendar.DATE, 1); a.roll(Calendar.DATE, -1); return a.get(Calendar.DATE); }
From source file:com.skipjaq.awspricing.pricing.AwsPricing.java
private static Date getDate(String dateTime) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); try {/* w w w .j a v a2s. c om*/ Date date = formatter.parse(dateTime); return date; } catch (ParseException e) { Date currentDate = new Date(); Calendar c = Calendar.getInstance(); c.setTime(currentDate); c.roll(Calendar.DAY_OF_MONTH, 1); Date yesterday = c.getTime(); System.out.println("Parse date time went wrong, getting yesterday " + yesterday); return yesterday; } }
From source file:Main.java
/** * Get month days by year, month//from w ww. j a v a 2 s . co m * * @param year * @param month * @return */ public static int getMonthDays(int year, int month) { Calendar a = Calendar.getInstance(); a.set(Calendar.YEAR, year); a.set(Calendar.MONTH, month - 1); a.set(Calendar.DATE, 1); a.roll(Calendar.DATE, -1); int maxDate = a.get(Calendar.DATE); return maxDate; }
From source file:org.toobsframework.transformpipeline.xslExtentions.DateHelper.java
public static String getDateLastWeek() { Calendar cal = new GregorianCalendar(); cal.roll(Calendar.DAY_OF_YEAR, -7); return String.valueOf(cal.getTimeInMillis()); }
From source file:org.toobsframework.transformpipeline.xslExtentions.DateHelper.java
public static String getDateNextWeek() { Calendar cal = new GregorianCalendar(); cal.roll(Calendar.DAY_OF_YEAR, +7); return String.valueOf(cal.getTimeInMillis()); }
From source file:org.toobsframework.transformpipeline.xslExtentions.DateHelper.java
public static String getDayNextWeek() { Calendar cal = new GregorianCalendar(); cal.roll(Calendar.DAY_OF_YEAR, +7); return String.valueOf(cal.get(Calendar.DAY_OF_MONTH)); }
From source file:org.toobsframework.transformpipeline.xslExtentions.DateHelper.java
public static String getDateNextMonth() { Calendar cal = new GregorianCalendar(); cal.roll(Calendar.MONTH, +1); return String.valueOf(cal.getTimeInMillis()); }
From source file:org.mousephenotype.dcc.exportlibrary.fullTraverser.FullTraverserTest.java
@BeforeClass public static void setup() { FullTraverserTest.newHibernateManager(); long TrackerID = 1L; Calendar firstNow = DatatypeConverter.now(); firstNow.roll(Calendar.DAY_OF_YEAR, -2); SubmissionSet submissionSet = null;/* ww w . j av a2 s .c o m*/ try { submissionSet = FullTraverserTest.loadData(TrackerID, firstNow); } catch (JAXBException | IOException ex) { logger.error("", ex); Assert.fail(); } Assert.assertNotNull(submissionSet); Assert.assertTrue(submissionSet.isSetSubmission()); Assert.assertFalse(submissionSet.getSubmission().isEmpty()); TrackerID++; Calendar secondRow = DatatypeConverter.now(); hibernateManager.persist(submissionSet); FullTraverserTest.hibernateManager.getEntityManager().close(); SubmissionSet sb2 = null; try { sb2 = FullTraverserTest.loadData(TrackerID, secondRow); } catch (JAXBException | IOException ex) { logger.error("", ex); Assert.fail(); } hibernateManager.persist(sb2); FullTraverserTest.fullTraverser = new FullTraverser(hibernateManager); }