There are 36 code examples for java.util.Calendar.

The API names are highlighted below. You can use suckoo button to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.

Project Name: druid Package: org.dlib.tools

Source Code: Util.java (Click to view .java file)

Method Code:
vote
like

public static String getCurrentTime(){
  Calendar c=Calendar.getInstance();
  String hour="" + c.get(Calendar.HOUR_OF_DAY);
  String min="" + c.get(Calendar.MINUTE);
  String sec="" + c.get(Calendar.SECOND);
  if (hour.length() == 1)   hour="0" + hour;
  if (min.length() == 1)   min="0" + min;
  if (sec.length() == 1)   sec="0" + sec;
  return hour + ":" + min+ ":"+ sec;
}
 

Project Name: icTAKES Package: edu.mayo.bmi.nlp.preprocessor

Source Code: ClinicalNotePreProcessor.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Given a drm string that may or may not contain the time, this method will
 * return a string.
 * @param drmStr
 * @return If something goes wrong, 0 is returned. Otherwise the time in
 * milliseconds is returned.
 */
private long convertTime(String drmStr) throws Exception {
  int tIndex=drmStr.indexOf('T');
  String dateStr=null;
  String timeStr=null;
  if (tIndex != -1) {
    dateStr=drmStr.substring(0,tIndex);
    timeStr=drmStr.substring(tIndex + 1,drmStr.length());
  }
 else {
    dateStr=drmStr;
  }
  try {
    if (dateStr.length() == 8) {
      int year=Integer.parseInt(dateStr.substring(0,4));
      int month=Integer.parseInt(dateStr.substring(4,6));
      int day=Integer.parseInt(dateStr.substring(6,8));
      Calendar c=new GregorianCalendar();
      c.clear();
      int hours=0;
      int minutes=0;
      int seconds=0;
      if (timeStr != null) {
        if (timeStr.length() >= 4) {
          hours=Integer.parseInt(timeStr.substring(0,2));
          minutes=Integer.parseInt(timeStr.substring(2,4));
        }
        if (timeStr.length() == 6) {
          seconds=Integer.parseInt(timeStr.substring(4,6));
        }
      }
      c.set(year,month - 1,day,hours,minutes,seconds);
      return c.getTime().getTime();
    }
 else {
      throw new Exception();
    }
  }
 catch (  Exception e) {
    throw new Exception("Invalid DRM. date=" + dateStr + " time="+ timeStr);
  }
}
 

Project Name: icTAKES Package: edu.mayo.bmi.uima.core.util

Source Code: DateParser.java (Click to view .java file)

Method Code:
vote
like

/** 
 * First try parsing full date (month, day and year) using java.util.Date
 * If that fails, try extracting at least part of the date
 * @param jcas
 * @param dateString
 * @return
 */
public static Date parse(JCas jcas,String dateString){
  Date date=new Date(jcas);
  try {
    java.util.Date jud=df.parse(dateString);
    date=new Date(jcas);
    cal.setTime(jud);
    date.setDay(Integer.toString(cal.get(Calendar.DAY_OF_MONTH)));
    date.setMonth(Integer.toString(cal.get(Calendar.MONTH) + 1));
    date.setYear(Integer.toString(cal.get(Calendar.YEAR)));
  }
 catch (  ParseException e) {
    dateString=dateString.trim().toLowerCase();
    for (int i=0; i < monthShortNames.size(); i++) {
      if (dateString.startsWith(monthShortNames.get(i))) {
        date.setMonth(dateString.substring(0,getIndexFirstNonLetter(dateString)));
      }
    }
    int yearPosition=getIndexAfterLastNonDigit(dateString);
    if (yearPosition + 4 == dateString.length()) {
      date.setYear(dateString.substring(yearPosition));
    }
  }
  return date;
}
 

Project Name: jFreeChart Package: org.jfree.chart.axis

Source Code: DateAxis.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns the first "standard" date (based on the specified field and
 * units).
 * @param date  the reference date.
 * @param unit  the date tick unit.
 * @return The next "standard" date.
 */
protected Date nextStandardDate(Date date,DateTickUnit unit){
  Date previous=previousStandardDate(date,unit);
  Calendar calendar=Calendar.getInstance(this.timeZone,this.locale);
  calendar.setTime(previous);
  calendar.add(unit.getCalendarField(),unit.getMultiple());
  return calendar.getTime();
}
 

Project Name: jFreeChart Package: org.jfree.chart.axis

Source Code: DateTickUnit.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Rolls the date forward by the amount specified by the roll unit and
 * count.
 * @param base  the base date.
 * @param zone  the time zone.
 * @return The rolled date.
 * @since 1.0.6
 */
public Date rollDate(Date base,TimeZone zone){
  Calendar calendar=Calendar.getInstance(zone);
  calendar.setTime(base);
  calendar.add(this.rollUnitType.getCalendarField(),this.rollCount);
  return calendar.getTime();
}
 

Project Name: jFreeChart Package: org.jfree.chart.axis

Source Code: MonthDateFormat.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Formats the given date.
 * @param date  the date.
 * @param toAppendTo  the string buffer.
 * @param fieldPosition  the field position.
 * @return The formatted date.
 */
public StringBuffer format(Date date,StringBuffer toAppendTo,FieldPosition fieldPosition){
  this.calendar.setTime(date);
  int month=this.calendar.get(Calendar.MONTH);
  toAppendTo.append(this.months[month]);
  if (this.showYear[month]) {
    toAppendTo.append(this.yearFormatter.format(date));
  }
  return toAppendTo;
}
 

Project Name: jFreeChart Package: org.jfree.chart.axis

Source Code: QuarterDateFormat.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Formats the given date.
 * @param date  the date.
 * @param toAppendTo  the string buffer.
 * @param fieldPosition  the field position.
 * @return The formatted date.
 */
public StringBuffer format(Date date,StringBuffer toAppendTo,FieldPosition fieldPosition){
  this.calendar.setTime(date);
  int year=this.calendar.get(Calendar.YEAR);
  int month=this.calendar.get(Calendar.MONTH);
  int quarter=month / 3;
  if (this.quarterFirst) {
    toAppendTo.append(this.quarters[quarter]);
    toAppendTo.append(" ");
    toAppendTo.append(year);
  }
 else {
    toAppendTo.append(year);
    toAppendTo.append(" ");
    toAppendTo.append(this.quarters[quarter]);
  }
  return toAppendTo;
}
 

Project Name: jFreeChart Package: org.jfree.chart.axis

Source Code: SegmentedTimeline.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Converts a millisecond value into a {@link Date} object.
 * @param value  the millisecond value.
 * @return The date.
 */
public Date getDate(long value){
  this.workingCalendarNoDST.setTime(new Date(value));
  return (this.workingCalendarNoDST.getTime());
}
 

Project Name: jFreeChart Package: org.jfree.chart.util

Source Code: RelativeDateFormat.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Creates a new instance.
 * @param baseMillis  the time zone (<code>null</code> not permitted).
 */
public RelativeDateFormat(long baseMillis){
  super();
  this.baseMillis=baseMillis;
  this.showZeroDays=false;
  this.showZeroHours=true;
  this.positivePrefix="";
  this.dayFormatter=NumberFormat.getNumberInstance();
  this.daySuffix="d";
  this.hourFormatter=NumberFormat.getNumberInstance();
  this.hourSuffix="h";
  this.minuteFormatter=NumberFormat.getNumberInstance();
  this.minuteSuffix="m";
  this.secondFormatter=NumberFormat.getNumberInstance();
  this.secondFormatter.setMaximumFractionDigits(3);
  this.secondFormatter.setMinimumFractionDigits(3);
  this.secondSuffix="s";
  this.calendar=new GregorianCalendar();
  this.numberFormat=new DecimalFormat("0");
}
 

Project Name: jFreeChart Package: org.jfree.data.time

Source Code: Minute.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns the last millisecond of the minute.
 * @param calendar  the calendar / timezone (<code>null</code> not
 * permitted).
 * @return The last millisecond.
 * @throws NullPointerException if <code>calendar</code> is
 * <code>null</code>.
 */
public long getLastMillisecond(Calendar calendar){
  int year=this.day.getYear();
  int month=this.day.getMonth() - 1;
  int day=this.day.getDayOfMonth();
  calendar.clear();
  calendar.set(year,month,day,this.hour,this.minute,59);
  calendar.set(Calendar.MILLISECOND,999);
  return calendar.getTime().getTime();
}
 

Project Name: jFreeChart Package: org.jfree.data.time

Source Code: Quarter.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns the last millisecond of the Quarter, evaluated using the
 * supplied calendar (which determines the time zone).
 * @param calendar  the calendar (<code>null</code> not permitted).
 * @return The last millisecond of the Quarter.
 * @throws NullPointerException if <code>calendar</code> is
 * <code>null</code>.
 */
public long getLastMillisecond(Calendar calendar){
  int month=Quarter.LAST_MONTH_IN_QUARTER[this.quarter];
  int eom=SerialDate.lastDayOfMonth(month,this.year);
  calendar.set(this.year,month - 1,eom,23,59,59);
  calendar.set(Calendar.MILLISECOND,999);
  return calendar.getTime().getTime();
}
 

Project Name: jFreeChart Package: org.jfree.data.time

Source Code: Day.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns the last millisecond of the day, evaluated using the supplied
 * calendar (which determines the time zone).
 * @param calendar  calendar to use (<code>null</code> not permitted).
 * @return The end of the day as milliseconds since 01-01-1970.
 * @throws NullPointerException if <code>calendar</code> is
 * <code>null</code>.
 */
public long getLastMillisecond(Calendar calendar){
  int year=this.serialDate.getYYYY();
  int month=this.serialDate.getMonth();
  int day=this.serialDate.getDayOfMonth();
  calendar.clear();
  calendar.set(year,month - 1,day,23,59,59);
  calendar.set(Calendar.MILLISECOND,999);
  return calendar.getTime().getTime();
}
 

Project Name: jFreeChart Package: org.jfree.data.time

Source Code: Second.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns the last millisecond of the second.
 * @param calendar  the calendar/timezone (<code>null</code> not permitted).
 * @return The last millisecond.
 * @throws NullPointerException if <code>calendar</code> is
 * <code>null</code>.
 */
public long getLastMillisecond(Calendar calendar){
  return getFirstMillisecond(calendar) + 999L;
}
 

Project Name: jFreeChart Package: org.jfree.data.time

Source Code: TimeTableXYDataset.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns a clone of this dataset.
 * @return A clone.
 * @throws CloneNotSupportedException if the dataset cannot be cloned.
 */
public Object clone() throws CloneNotSupportedException {
  TimeTableXYDataset clone=(TimeTableXYDataset)super.clone();
  clone.values=(DefaultKeyedValues2D)this.values.clone();
  clone.workingCalendar=(Calendar)this.workingCalendar.clone();
  return clone;
}
 

Project Name: jFreeChart Package: org.jfree.data.time

Source Code: Week.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns the last millisecond of the week, evaluated using the supplied
 * calendar (which determines the time zone).
 * @param calendar  the calendar (<code>null</code> not permitted).
 * @return The last millisecond of the week.
 * @throws NullPointerException if <code>calendar</code> is
 * <code>null</code>.
 */
public long getLastMillisecond(Calendar calendar){
  Calendar c=(Calendar)calendar.clone();
  c.clear();
  c.set(Calendar.YEAR,this.year);
  c.set(Calendar.WEEK_OF_YEAR,this.week + 1);
  c.set(Calendar.DAY_OF_WEEK,c.getFirstDayOfWeek());
  c.set(Calendar.HOUR,0);
  c.set(Calendar.MINUTE,0);
  c.set(Calendar.SECOND,0);
  c.set(Calendar.MILLISECOND,0);
  return c.getTime().getTime() - 1;
}
 

Project Name: jFreeChart Package: org.jfree.data.time

Source Code: Year.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns the last millisecond of the year, evaluated using the supplied
 * calendar (which determines the time zone).
 * @param calendar  the calendar (<code>null</code> not permitted).
 * @return The last millisecond of the year.
 * @throws NullPointerException if <code>calendar</code> is
 * <code>null</code>.
 */
public long getLastMillisecond(Calendar calendar){
  calendar.set(this.year,Calendar.DECEMBER,31,23,59,59);
  calendar.set(Calendar.MILLISECOND,999);
  return calendar.getTime().getTime();
}
 

Project Name: jFreeChart Package: org.jfree.data.time

Source Code: TimeSeriesCollection.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns a clone of this time series collection.
 * @return A clone.
 * @throws java.lang.CloneNotSupportedException
 */
public Object clone() throws CloneNotSupportedException {
  TimeSeriesCollection clone=(TimeSeriesCollection)super.clone();
  clone.data=(List)ObjectUtilities.deepClone(this.data);
  clone.workingCalendar=(Calendar)this.workingCalendar.clone();
  return clone;
}
 

Project Name: jFreeChart Package: org.jfree.data.time

Source Code: Millisecond.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns the last millisecond of the time period.
 * @param calendar  the calendar (<code>null</code> not permitted).
 * @return The last millisecond of the time period.
 * @throws NullPointerException if <code>calendar</code> is
 * <code>null</code>.
 */
public long getLastMillisecond(Calendar calendar){
  return getFirstMillisecond(calendar);
}
 

Project Name: jFreeChart Package: org.jfree.data.time

Source Code: DynamicTimeSeriesCollection.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns the x-value for a time period.
 * @param period  the period.
 * @return The x-value.
 */
private long getX(RegularTimePeriod period){
switch (this.position) {
case (START):
    return period.getFirstMillisecond(this.workingCalendar);
case (MIDDLE):
  return period.getMiddleMillisecond(this.workingCalendar);
case (END):
return period.getLastMillisecond(this.workingCalendar);
default :
return period.getMiddleMillisecond(this.workingCalendar);
}
}
 

Project Name: jFreeChart Package: org.jfree.data.time

Source Code: Month.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns the last millisecond of the month, evaluated using the supplied
 * calendar (which determines the time zone).
 * @param calendar  the calendar (<code>null</code> not permitted).
 * @return The last millisecond of the month.
 * @throws NullPointerException if <code>calendar</code> is
 * <code>null</code>.
 */
public long getLastMillisecond(Calendar calendar){
  int eom=SerialDate.lastDayOfMonth(this.month,this.year);
  calendar.set(this.year,this.month - 1,eom,23,59,59);
  calendar.set(Calendar.MILLISECOND,999);
  return calendar.getTime().getTime();
}
 

Project Name: jFreeChart Package: org.jfree.data.time

Source Code: FixedMillisecond.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns the millisecond closest to the middle of the time period.
 * @param calendar  the calendar.
 * @return The millisecond closest to the middle of the time period.
 */
public long getMiddleMillisecond(Calendar calendar){
  return this.time;
}
 

Project Name: jFreeChart Package: org.jfree.data.time

Source Code: Hour.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns the last millisecond of the hour.
 * @param calendar  the calendar/timezone (<code>null</code> not permitted).
 * @return The last millisecond.
 * @throws NullPointerException if <code>calendar</code> is
 * <code>null</code>.
 */
public long getLastMillisecond(Calendar calendar){
  int year=this.day.getYear();
  int month=this.day.getMonth() - 1;
  int dom=this.day.getDayOfMonth();
  calendar.set(year,month,dom,this.hour,59,59);
  calendar.set(Calendar.MILLISECOND,999);
  return calendar.getTime().getTime();
}
 

Project Name: jFreeChart Package: org.jfree.data.time

Source Code: RegularTimePeriod.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Returns the millisecond closest to the middle of the time period,
 * evaluated using the supplied calendar (which incorporates a timezone).
 * @param calendar  the calendar.
 * @return The middle millisecond.
 */
public long getMiddleMillisecond(Calendar calendar){
  long m1=getFirstMillisecond(calendar);
  long m2=getLastMillisecond(calendar);
  return m1 + (m2 - m1) / 2;
}
 

Project Name: jbidwatcher Package: com.jbidwatcher.app

Source Code: UIBackbone.java (Click to view .java file)

Method Code:
vote
like

/** 
 * @param newStatus The text to place on the status line.
 * @brief Sets the text in the status bar on the bottom of the screen.
 */
private void setStatus(String newStatus){
  mNow.setTime(System.currentTimeMillis());
  String defaultServerTime=AuctionServerManager.getInstance().getDefaultServerTime();
  String bracketed=" [" + defaultServerTime + ']';
  if (JConfig.queryConfiguration("timesync.enabled","true").equals("false")) {
    TimeZone tz=AuctionServerManager.getInstance().getServer().getOfficialServerTimeZone();
    if (tz != null && tz.hasSameRules(mCal.getTimeZone())) {
      bracketed=" [" + Constants.localClockFormat.format(mNow) + ']';
    }
  }
  String statusToDisplay=newStatus + bracketed;
  if (mFrame != null) {
    mFrame.setStatus(statusToDisplay);
  }
 else {
    JConfig.log().logDebug(newStatus + bracketed);
  }
}
 

Project Name: openhotelsystem Package: it.hotel.controller.pricelist

Source Code: PriceListMultiFormControllerGlobal.java (Click to view .java file)

Method Code:
vote
like

/** 
 * @throws
	 * @
 * return
 */
protected Map referenceData(HttpServletRequest req) throws Exception {
  Map map=new HashMap();
  Calendar calendar=new GregorianCalendar(2009,11,12);
  req.setAttribute("calendar",calendar);
  return map;
}
 

Project Name: openhotelsystem Package: it.hotel.model

Source Code: CalendarUtils.java (Click to view .java file)

Method Code:
vote
like

/** 
 * @param startDate
 * @param endDate
 * @return the number of the days in the specified date range
 */
public static long daysBetween(Calendar startDate,Calendar endDate){
  Calendar date=(Calendar)startDate.clone();
  long daysBetween=0;
  while (date.before(endDate)) {
    date.add(Calendar.DAY_OF_MONTH,1);
    daysBetween++;
  }
  return daysBetween;
}
 

Project Name: openhotelsystem Package: it.hotel.model.booking

Source Code: ConfirmedBooking.java (Click to view .java file)

Method Code:
vote
like

/** 
 * get the number of days between the given dates
 * @param startDate
 * @param endDate
 * @return
 */
public static long daysBetween(Calendar startDate,Calendar endDate){
  Calendar date=(Calendar)startDate.clone();
  long daysBetween=0;
  while (date.before(endDate)) {
    date.add(Calendar.DAY_OF_MONTH,1);
    daysBetween++;
  }
  return daysBetween;
}
 

Project Name: openhotelsystem Package: it.hotel.model.service

Source Code: Service.java (Click to view .java file)

Method Code:
vote
like

public void setDateadded(Calendar dateadded){
  this.dateadded=dateadded;
  this.prettydate=CalendarUtils.GetFormat().format(dateadded.getTime());
}
 

Project Name: rssowl.core Package: org.rssowl.core.internal.persist.search

Source Code: ModelSearchQueries.java (Click to view .java file)

Method Code:
vote
like

private static Query createAgeClause(ISearchCondition condition){
  Integer age=(Integer)condition.getValue();
  String value;
  if (age < 0) {
    Calendar cal=Calendar.getInstance();
    cal.setTimeInMillis(System.currentTimeMillis() + age * MINUTE);
    value=DateTools.dateToString(cal.getTime(),Resolution.MINUTE);
    String fieldname=String.valueOf(INews.AGE_IN_MINUTES);
    return createAgeQuery(condition,fieldname,value);
  }
  Calendar cal=Calendar.getInstance();
  cal.setTimeInMillis(System.currentTimeMillis() - age * DAY);
  value=DateTools.dateToString(cal.getTime(),Resolution.DAY);
  String fieldname=String.valueOf(INews.AGE_IN_DAYS);
  return createAgeQuery(condition,fieldname,value);
}
 

Project Name: rssowl.core Package: org.rssowl.core.util

Source Code: DateUtils.java (Click to view .java file)

Method Code:
vote
like

/** 
 * @return A Calendar instance with the time being Today with a Time of
 * 0:00:00
 */
public static Calendar getToday(){
  Calendar today=Calendar.getInstance();
  today.set(Calendar.HOUR_OF_DAY,0);
  today.set(Calendar.MINUTE,0);
  today.set(Calendar.SECOND,0);
  today.set(Calendar.MILLISECOND,0);
  return today;
}
 

Project Name: rssowl.ui Package: org.rssowl.ui.internal

Source Code: OwlUI.java (Click to view .java file)

Method Code:
vote
like

/** 
 * @return the width for displaying a date.
 */
public static int getDateWidth(){
  if (DATE_WIDTH > 0)   return DATE_WIDTH;
  DateFormat dF=getShortDateFormat();
  Calendar cal=Calendar.getInstance();
  cal.set(2006,Calendar.DECEMBER,12,12,12,12);
  String sampleDate=dF.format(cal.getTime());
  DATE_WIDTH=OwlUI.getTextSize(Display.getDefault(),OwlUI.getBold(HEADLINES_FONT_ID),sampleDate).x;
  DATE_WIDTH+=Application.IS_WINDOWS ? 15 : 30;
  return DATE_WIDTH;
}
 

Project Name: rssowl.ui Package: org.rssowl.ui.internal.editors.feed

Source Code: NewsGrouping.java (Click to view .java file)

Method Code:
vote
like

private List<EntityGroup> createDateGroups(Collection<INews> input){
  Calendar today=DateUtils.getToday();
  long todayMillis=today.getTimeInMillis();
  Date yesterday=new Date(todayMillis - DAY);
  today.set(Calendar.DAY_OF_WEEK,today.getFirstDayOfWeek());
  Date earlierThisWeek=today.getTime();
  Date lastWeek=new Date(earlierThisWeek.getTime() - WEEK);
  EntityGroup gToday=new EntityGroup(Group.TODAY.ordinal(),GROUP_CATEGORY_ID,Group.TODAY.getName());
  EntityGroup gYesterday=new EntityGroup(Group.YESTERDAY.ordinal(),GROUP_CATEGORY_ID,Group.YESTERDAY.getName());
  EntityGroup gEarlierThisWeek=new EntityGroup(Group.EARLIER_THIS_WEEK.ordinal(),GROUP_CATEGORY_ID,Group.EARLIER_THIS_WEEK.getName());
  EntityGroup gLastWeek=new EntityGroup(Group.LAST_WEEK.ordinal(),GROUP_CATEGORY_ID,Group.LAST_WEEK.getName());
  EntityGroup gOlder=new EntityGroup(Group.OLDER.ordinal(),GROUP_CATEGORY_ID,Group.OLDER.getName());
  for (  Object object : input) {
    if (object instanceof INews) {
      INews news=(INews)object;
      Date date=DateUtils.getRecentDate(news);
      if (date.getTime() >= todayMillis)       new EntityGroupItem(gToday,news);
 else       if (date.compareTo(yesterday) >= 0)       new EntityGroupItem(gYesterday,news);
 else       if (date.compareTo(earlierThisWeek) >= 0)       new EntityGroupItem(gEarlierThisWeek,news);
 else       if (date.compareTo(lastWeek) >= 0)       new EntityGroupItem(gLastWeek,news);
 else       new EntityGroupItem(gOlder,news);
    }
  }
  return maskEmpty(new ArrayList<EntityGroup>(Arrays.asList(new EntityGroup[]{gToday,gYesterday,gEarlierThisWeek,gLastWeek,gOlder})));
}
 

Project Name: rssowl.ui Package: org.rssowl.ui.internal.views.explorer

Source Code: BookMarkGrouping.java (Click to view .java file)

Method Code:
vote
like

private EntityGroup[] createLastVisitDateGroups(List<? extends IEntity> input){
  Calendar today=DateUtils.getToday();
  long todayMillis=today.getTimeInMillis();
  Date yesterday=new Date(todayMillis - DAY);
  today.set(Calendar.DAY_OF_WEEK,today.getFirstDayOfWeek());
  Date earlierThisWeek=today.getTime();
  Date lastWeek=new Date(earlierThisWeek.getTime() - WEEK);
  EntityGroup gToday=new EntityGroup(Group.TODAY.ordinal(),GROUP_CATEGORY_ID,Group.TODAY.getName());
  EntityGroup gYesterday=new EntityGroup(Group.YESTERDAY.ordinal(),GROUP_CATEGORY_ID,Group.YESTERDAY.getName());
  EntityGroup gEarlierThisWeek=new EntityGroup(Group.EARLIER_THIS_WEEK.ordinal(),GROUP_CATEGORY_ID,Group.EARLIER_THIS_WEEK.getName());
  EntityGroup gLastWeek=new EntityGroup(Group.LAST_WEEK.ordinal(),GROUP_CATEGORY_ID,Group.LAST_WEEK.getName());
  EntityGroup gOlder=new EntityGroup(Group.OLDER.ordinal(),GROUP_CATEGORY_ID,Group.OLDER.getName());
  EntityGroup gNever=new EntityGroup(Group.NEVER.ordinal(),GROUP_CATEGORY_ID,Group.NEVER.getName());
  for (  Object object : input) {
    if (object instanceof IMark) {
      IMark mark=(IMark)object;
      Date lastVisitDate=mark.getLastVisitDate();
      if (lastVisitDate == null)       new EntityGroupItem(gNever,mark);
 else       if (lastVisitDate.getTime() >= todayMillis)       new EntityGroupItem(gToday,mark);
 else       if (lastVisitDate.compareTo(yesterday) >= 0)       new EntityGroupItem(gYesterday,mark);
 else       if (lastVisitDate.compareTo(earlierThisWeek) >= 0)       new EntityGroupItem(gEarlierThisWeek,mark);
 else       if (lastVisitDate.compareTo(lastWeek) >= 0)       new EntityGroupItem(gLastWeek,mark);
 else       new EntityGroupItem(gOlder,mark);
    }
  }
  return maskEmpty(new ArrayList<EntityGroup>(Arrays.asList(new EntityGroup[]{gNever,gToday,gYesterday,gEarlierThisWeek,gLastWeek,gOlder})));
}
 

Project Name: weka Package: weka.experiment

Source Code: CrossValidationResultProducer.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Gets a Double representing the current date and time.
 * eg: 1:46pm on 20/5/1999 -> 19990520.1346
 * @return a value of type Double
 */
public static Double getTimestamp(){
  Calendar now=Calendar.getInstance(TimeZone.getTimeZone("UTC"));
  double timestamp=now.get(Calendar.YEAR) * 10000 + (now.get(Calendar.MONTH) + 1) * 100 + now.get(Calendar.DAY_OF_MONTH) + now.get(Calendar.HOUR_OF_DAY) / 100.0 + now.get(Calendar.MINUTE) / 10000.0;
  return new Double(timestamp);
}
 

Project Name: weka Package: weka.experiment

Source Code: ExplicitTestsetResultProducer.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Gets a Double representing the current date and time.
 * eg: 1:46pm on 20/5/1999 -> 19990520.1346
 * @return 		a value of type Double
 */
public static Double getTimestamp(){
  Calendar now=Calendar.getInstance(TimeZone.getTimeZone("UTC"));
  double timestamp=now.get(Calendar.YEAR) * 10000 + (now.get(Calendar.MONTH) + 1) * 100 + now.get(Calendar.DAY_OF_MONTH) + now.get(Calendar.HOUR_OF_DAY) / 100.0 + now.get(Calendar.MINUTE) / 10000.0;
  return new Double(timestamp);
}
 

Project Name: weka Package: weka.experiment

Source Code: RandomSplitResultProducer.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Gets a Double representing the current date and time.
 * eg: 1:46pm on 20/5/1999 -> 19990520.1346
 * @return a value of type Double
 */
public static Double getTimestamp(){
  Calendar now=Calendar.getInstance(TimeZone.getTimeZone("UTC"));
  double timestamp=now.get(Calendar.YEAR) * 10000 + (now.get(Calendar.MONTH) + 1) * 100 + now.get(Calendar.DAY_OF_MONTH) + now.get(Calendar.HOUR_OF_DAY) / 100.0 + now.get(Calendar.MINUTE) / 10000.0;
  return new Double(timestamp);
}