Java Code Examples for java.util.GregorianCalendar

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project ALP, under directory /workspace/alp-reporter/src/main/java/com/lohika/alp/reporter/.

Source file: ResultsXML.java

  19 
vote

/** 
 * New xml gregorian calendar.
 * @param millis the millis
 * @return the xML gregorian calendar
 */
protected XMLGregorianCalendar newXMLGregorianCalendar(long millis){
  try {
    DatatypeFactory datatypeFactory=DatatypeFactory.newInstance();
    GregorianCalendar cal=new GregorianCalendar();
    return datatypeFactory.newXMLGregorianCalendar(cal);
  }
 catch (  DatatypeConfigurationException e) {
    logger.error(e);
    return null;
  }
}
 

Example 2

From project android_packages_apps_Exchange, under directory /src/com/android/exchange/utility/.

Source file: CalendarUtilities.java

  19 
vote

static void putTransitionMillisIntoSystemTime(byte[] bytes,int offset,long millis){
  GregorianCalendar cal=new GregorianCalendar(TimeZone.getDefault());
  cal.setTimeInMillis(millis + 30 * SECONDS);
  setWord(bytes,offset + MSFT_SYSTEMTIME_MONTH,cal.get(Calendar.MONTH) + 1);
  setWord(bytes,offset + MSFT_SYSTEMTIME_DAY_OF_WEEK,cal.get(Calendar.DAY_OF_WEEK) - 1);
  int wom=cal.get(Calendar.DAY_OF_WEEK_IN_MONTH);
  setWord(bytes,offset + MSFT_SYSTEMTIME_DAY,wom < 0 ? 5 : wom);
  setWord(bytes,offset + MSFT_SYSTEMTIME_HOUR,getTrueTransitionHour(cal));
  setWord(bytes,offset + MSFT_SYSTEMTIME_MINUTE,getTrueTransitionMinute(cal));
}
 

Example 3

From project any23, under directory /core/src/main/java/org/apache/any23/rdf/.

Source file: RDFUtils.java

  19 
vote

/** 
 * This method allows to obtain an <a href="http://www.w3.org/TR/xmlschema-2/#date">XML Schema</a> compliant date providing a textual representation of a date and textual a pattern for parsing it.
 * @param dateToBeParsed the String containing the date.
 * @param format the pattern as descibed in {@link java.text.SimpleDateFormat}
 * @return a {@link String} representing the date
 * @throws java.text.ParseException
 * @throws javax.xml.datatype.DatatypeConfigurationException
 */
public static String getXSDDate(String dateToBeParsed,String format) throws ParseException, DatatypeConfigurationException {
  SimpleDateFormat simpleDateFormat=new SimpleDateFormat(format);
  Date date=simpleDateFormat.parse(dateToBeParsed);
  GregorianCalendar gc=new GregorianCalendar();
  gc.setTime(date);
  XMLGregorianCalendar xml=DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
  xml.setTimezone(0);
  return xml.toString();
}
 

Example 4

From project apg, under directory /src/org/thialfihar/android/apg/.

Source file: Apg.java

  19 
vote

private static long getNumDaysBetween(GregorianCalendar first,GregorianCalendar second){
  GregorianCalendar tmp=new GregorianCalendar();
  tmp.setTime(first.getTime());
  long numDays=(second.getTimeInMillis() - first.getTimeInMillis()) / 1000 / 86400;
  tmp.add(Calendar.DAY_OF_MONTH,(int)numDays);
  while (tmp.before(second)) {
    tmp.add(Calendar.DAY_OF_MONTH,1);
    ++numDays;
  }
  return numDays;
}
 

Example 5

From project activejdbc, under directory /activejdbc/src/test/java/org/javalite/activejdbc/test/.

Source file: ActiveJDBCTest.java

  18 
vote

/** 
 * there is nothing more annoying than Java date/time APIs!
 * @param year
 * @param month
 * @param day
 * @return
 */
public long getTime(int year,int month,int day){
  GregorianCalendar calendar=new GregorianCalendar();
  calendar.set(Calendar.YEAR,year);
  calendar.set(Calendar.MONTH,month - 1);
  calendar.set(Calendar.DATE,day);
  calendar.set(Calendar.HOUR,0);
  calendar.set(Calendar.MINUTE,0);
  calendar.set(Calendar.SECOND,0);
  calendar.set(Calendar.MILLISECOND,0);
  return calendar.getTime().getTime();
}
 

Example 6

From project Carolina-Digital-Repository, under directory /fcrepo-irods-storage/src/main/java/fedorax/server/module/storage/lowlevel/irods/.

Source file: TimestampPathAlgorithm.java

  18 
vote

public String format(String pid) throws LowlevelStorageException {
  GregorianCalendar calendar=new GregorianCalendar();
  String year=Integer.toString(calendar.get(Calendar.YEAR));
  String month=leftPadded(1 + calendar.get(Calendar.MONTH),2);
  String dayOfMonth=leftPadded(calendar.get(Calendar.DAY_OF_MONTH),2);
  String hourOfDay=leftPadded(calendar.get(Calendar.HOUR_OF_DAY),2);
  String minute=leftPadded(calendar.get(Calendar.MINUTE),2);
  return storeBase + SEP + year+ SEP+ month+ dayOfMonth+ SEP+ hourOfDay+ SEP+ minute+ SEP+ pid;
}
 

Example 7

From project caseconductor-platform, under directory /utest-common/src/main/java/com/utest/util/.

Source file: DateUtil.java

  18 
vote

/** 
 * @return Adds the given number of days to the given date and return acopy.
 */
public static Date addDays(final Date date,final int days){
  final GregorianCalendar gc=new GregorianCalendar();
  gc.setTime(date);
  gc.add(Calendar.DAY_OF_MONTH,days);
  return gc.getTime();
}
 

Example 8

From project chililog-server, under directory /src/main/java/org/chililog/server/workbench/workers/.

Source file: RepositoryConfigWorker.java

  18 
vote

/** 
 * <p> Get a list of all users so we can figure out which user can access which repository </p> <p> Note that we cache for 30 seconds. </p>
 * @param db Database connection
 * @return List of all users
 * @throws ChiliLogException
 */
private static synchronized UserBO[] getAllUsers(DB db) throws ChiliLogException {
  if (_userListCache == null || _userListCacheExpiry.before(new Date())) {
    UserListCriteria criteria=new UserListCriteria();
    ArrayList<UserBO> list=UserController.getInstance().getList(db,criteria);
    _userListCache=list.toArray(new UserBO[]{});
    GregorianCalendar cal=new GregorianCalendar();
    cal.add(Calendar.SECOND,10);
    _userListCacheExpiry=cal.getTime();
  }
  return _userListCache;
}
 

Example 9

From project commons-mom, under directory /src/test/java/com/zauberlabs/commons/mom/ext/converter/.

Source file: DateToXMLGregorianCalendarTypeConverterUnitTest.java

  18 
vote

/** 
 */
@Test public void convertsDatesToXmlGregorianCalendars() throws Exception {
  final Date date=new Date();
  final XMLGregorianCalendar result=DateToXMLGregorianCalendarTypeConverter.converter().convert(date,XMLGregorianCalendar.class);
  GregorianCalendar calendar=new GregorianCalendar();
  calendar.setTime(date);
  assertEquals(calendar.get(Calendar.YEAR),result.getYear());
  assertEquals(calendar.get(Calendar.DAY_OF_MONTH),result.getDay());
  assertEquals(calendar.get(Calendar.MONTH) + 1,result.getMonth());
}
 

Example 10

From project cron, under directory /providers/scheduling/quartz/src/main/java/org/jboss/seam/cron/scheduling/quartz/.

Source file: QuartzScheduleProvider.java

  18 
vote

private GregorianCalendar startInOneSecond(final Trigger schedTrigger){
  GregorianCalendar gc=getOneSecondLater();
  final Date startTime=new Date(gc.getTimeInMillis());
  schedTrigger.setStartTime(startTime);
  return gc;
}
 

Example 11

From project cw-omnibus, under directory /WidgetCatalog/DatePicker/src/com/commonsware/android/wc/datepick/.

Source file: DatePickerDemoActivity.java

  18 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  CheckBox cb=(CheckBox)findViewById(R.id.showCalendar);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    cb.setOnCheckedChangeListener(this);
  }
 else {
    cb.setVisibility(View.GONE);
  }
  GregorianCalendar now=new GregorianCalendar();
  picker=(DatePicker)findViewById(R.id.picker);
  picker.init(now.get(Calendar.YEAR),now.get(Calendar.MONTH),now.get(Calendar.DAY_OF_MONTH),this);
}
 

Example 12

From project descriptors, under directory /impl-base/src/main/java/org/jboss/shrinkwrap/descriptor/impl/base/.

Source file: XMLDate.java

  18 
vote

public static synchronized String toXMLFormat(java.util.Date start){
  try {
    GregorianCalendar gCal=(GregorianCalendar)GregorianCalendar.getInstance();
    gCal.setTime(start);
    XMLGregorianCalendar cal=DatatypeFactory.newInstance().newXMLGregorianCalendar(gCal);
    return cal.toXMLFormat();
  }
 catch (  DatatypeConfigurationException ex) {
    throw new RuntimeException(ex);
  }
}
 

Example 13

From project dozer, under directory /core/src/test/java/org/dozer/converters/.

Source file: DateConverterTest.java

  18 
vote

@Test public void testXmlGregorianCalendar(){
  XMLGregorianCalendar xmlCalendar=mock(XMLGregorianCalendar.class);
  GregorianCalendar expected=new GregorianCalendar();
  when(xmlCalendar.toGregorianCalendar()).thenReturn(expected);
  Date date=new Date(expected.getTimeInMillis());
  assertEquals(date,converter.convert(Date.class,xmlCalendar));
}
 

Example 14

From project DTRules, under directory /dtrules-engine/src/main/java/com/dtrules/interpreter/operators/.

Source file: RDateTimeOps.java

  18 
vote

public void execute(DTState state) throws RulesException {
  GregorianCalendar calendar=new GregorianCalendar();
  calendar.setTime(state.datapop().timeValue());
  if (calendar.isLeapYear(calendar.get(Calendar.YEAR))) {
    state.datapush(RInteger.getRIntegerValue(366));
  }
 else {
    state.datapush(RInteger.getRIntegerValue(365));
  }
}
 

Example 15

From project EasySOA, under directory /easysoa-proxy/easysoa-proxy-intents/easysoa-proxy-intents-cxfMonitoringIntent/src/main/java/org/talend/esb/sam/agent/util/.

Source file: Converter.java

  18 
vote

/** 
 * convert Date to XMLGregorianCalendar.
 * @param date the date
 * @return the xML gregorian calendar
 */
public static XMLGregorianCalendar convertDate(Date date){
  if (date == null) {
    return null;
  }
  GregorianCalendar gc=new GregorianCalendar();
  gc.setTimeInMillis(date.getTime());
  try {
    return DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
  }
 catch (  DatatypeConfigurationException ex) {
    return null;
  }
}
 

Example 16

From project encog-java-core, under directory /src/main/java/org/encog/util/time/.

Source file: NumericDateUtil.java

  18 
vote

public static long date2Long(Date time){
  GregorianCalendar gc=new GregorianCalendar();
  gc.setTime(time);
  int month=gc.get(Calendar.MONTH) + 1;
  int day=gc.get(Calendar.DAY_OF_MONTH);
  int year=gc.get(Calendar.YEAR);
  return (long)(day + (month * MONTH_OFFSET) + (year * YEAR_OFFSET));
}
 

Example 17

From project Activiti-KickStart, under directory /activiti-kickstart-java/src/main/java/org/activiti/kickstart/service/alfresco/.

Source file: AlfrescoKickstartServiceImpl.java

  17 
vote

public List<KickstartWorkflowInfo> findWorkflowInformation(boolean includeCounts){
  if (includeCounts) {
    throw new UnsupportedOperationException();
  }
  Session cmisSession=getCmisSession();
  Folder workflowDefinitionFolder=(Folder)cmisSession.getObjectByPath(WORKFLOW_DEFINITION_FOLDER);
  String query="select t.cm:description, d." + PropertyIds.NAME + ", d."+ PropertyIds.CREATION_DATE+ " from cmis:document as d join cm:titled as t on d.cmis:objectId = t.cmis:objectId where in_folder(d, '"+ workflowDefinitionFolder.getId()+ "') and d.cmis:name LIKE '%.bpmn20.xml' order by d.cmis:name";
  LOGGER.info("Executing CMIS query '" + query + "'");
  ItemIterable<QueryResult> results=cmisSession.query(query,false);
  ArrayList<KickstartWorkflowInfo> workflowInfos=new ArrayList<KickstartWorkflowInfo>();
  for (  QueryResult result : results) {
    KickstartWorkflowInfo kickstartWorkflowInfo=new KickstartWorkflowInfo();
    kickstartWorkflowInfo.setName((String)result.getPropertyValueById("cm:description"));
    kickstartWorkflowInfo.setId(processNameToBaseName((String)result.getPropertyValueById(PropertyIds.NAME)));
    GregorianCalendar createDate=result.getPropertyValueById(PropertyIds.CREATION_DATE);
    kickstartWorkflowInfo.setCreateTime(createDate.getTime());
    workflowInfos.add(kickstartWorkflowInfo);
  }
  return workflowInfos;
}
 

Example 18

From project addis, under directory /application/src/test/java/org/drugis/addis/util/jaxb/.

Source file: JAXBConvertorTest.java

  17 
vote

@Test public void testDateWithNotes(){
  final Date oldXmlDate=new GregorianCalendar(2010,11 - 1,12).getTime();
  final DateWithNotes dwn=JAXBConvertor.dateWithNotes(oldXmlDate);
  final XMLGregorianCalendar cal=JAXBConvertor.dateToXml(oldXmlDate);
  final DateWithNotes dwn2=new DateWithNotes();
  dwn2.setNotes(new Notes());
  dwn2.setValue(cal);
  assertEquals(dwn,dwn2);
}
 

Example 19

From project agileBase, under directory /gtpb_server/src/com/gtwm/pb/model/manageData/fields/.

Source file: DateValueDefn.java

  17 
vote

public DateValueDefn(Date date){
  if (date == null) {
    this.year=null;
    this.month=null;
    this.dayOfMonth=null;
    this.hourOfDay=null;
    this.minute=null;
    this.second=null;
  }
 else {
    GregorianCalendar dateValue=new GregorianCalendar();
    dateValue.setTime(date);
    this.year=dateValue.get(Calendar.YEAR);
    this.month=dateValue.get(Calendar.MONTH) + 1;
    this.dayOfMonth=dateValue.get(Calendar.DAY_OF_MONTH);
    this.hourOfDay=dateValue.get(Calendar.HOUR_OF_DAY);
    this.minute=dateValue.get(Calendar.MINUTE);
    this.second=dateValue.get(Calendar.SECOND);
  }
}
 

Example 20

From project android-rss, under directory /src/test/java/org/mcsoxford/rss/.

Source file: RSSParserTest.java

  17 
vote

@Test public void parse() throws Exception {
  final RSSFeed feed=parse(stream);
  assertEquals("Example Channel",feed.getTitle());
  assertEquals(Uri.parse("http://example.com/"),feed.getLink());
  assertEquals("My example channel",feed.getDescription());
  final Iterator<RSSItem> items=feed.getItems().iterator();
  RSSItem item;
  item=items.next();
  assertEquals("News for November",item.getTitle());
  assertEquals(Uri.parse("http://example.com/2010/11/07"),item.getLink());
  assertEquals("Other things happened today",item.getDescription());
  assertTrue(item.getCategories().isEmpty());
  GregorianCalendar calendar=new GregorianCalendar(2010,10,07,8,22,14);
  calendar.setTimeZone(TimeZone.getTimeZone("Etc/GMT"));
  Date expectedDate=calendar.getTime();
  assertEquals(expectedDate,item.getPubDate());
  assertEquals(2,item.getThumbnails().size());
  MediaThumbnail expectedThumbnail0=new MediaThumbnail(Uri.parse("http://example.com/media/images/12/jpg/_7_2.jpg"),49,66);
  assertEquals(expectedThumbnail0.getUrl(),item.getThumbnails().get(0).getUrl());
  assertEquals(expectedThumbnail0.getHeight(),item.getThumbnails().get(0).getHeight());
  assertEquals(expectedThumbnail0.getWidth(),item.getThumbnails().get(0).getWidth());
  MediaThumbnail expectedThumbnail1=new MediaThumbnail(Uri.parse("http://example.com/media/images/12/jpg/_7_2-1.jpg"),81,144);
  assertEquals(expectedThumbnail1.getUrl(),item.getThumbnails().get(1).getUrl());
  assertEquals(expectedThumbnail1.getHeight(),item.getThumbnails().get(1).getHeight());
  assertEquals(expectedThumbnail1.getWidth(),item.getThumbnails().get(1).getWidth());
  item=items.next();
  assertEquals("News for October",item.getTitle());
  assertEquals(Uri.parse("http://example.com/2010/10/12"),item.getLink());
  assertEquals("October days: we&#8217;re, <b>apple</b> ##<i>pie</i>",item.getDescription());
  assertEquals("October days: we&#8217;re, <b>apple</b> ##<i>pie</i>",item.getContent());
  assertEquals(2,item.getCategories().size());
  assertTrue(item.getCategories().contains("Daily news"));
  assertTrue(item.getCategories().contains("October news"));
  assertEquals(0,item.getThumbnails().size());
  assertFalse(items.hasNext());
}
 

Example 21

From project Android-Simple-Social-Sharing, under directory /SimpleSocialSharing/src/com/nostra13/socialsharing/twitter/extpack/winterwell/jtwitter/.

Source file: InternalUtils.java

  17 
vote

/** 
 * Convenience method for making Dates. Because Date is a tricksy bugger of a class.
 * @param year
 * @param month
 * @param day
 * @return date object
 */
public static Date getDate(int year,String month,int day){
  try {
    Field field=GregorianCalendar.class.getField(month.toUpperCase());
    int m=field.getInt(null);
    Calendar date=new GregorianCalendar(year,m,day);
    return date.getTime();
  }
 catch (  Exception x) {
    throw new IllegalArgumentException(x.getMessage());
  }
}
 

Example 22

From project android_8, under directory /src/com/google/gson/.

Source file: DefaultTypeAdapters.java

  17 
vote

@Override public GregorianCalendar deserialize(JsonElement json,Type typeOfT,JsonDeserializationContext context) throws JsonParseException {
  JsonObject obj=json.getAsJsonObject();
  int year=obj.get(YEAR).getAsInt();
  int month=obj.get(MONTH).getAsInt();
  int dayOfMonth=obj.get(DAY_OF_MONTH).getAsInt();
  int hourOfDay=obj.get(HOUR_OF_DAY).getAsInt();
  int minute=obj.get(MINUTE).getAsInt();
  int second=obj.get(SECOND).getAsInt();
  return new GregorianCalendar(year,month,dayOfMonth,hourOfDay,minute,second);
}
 

Example 23

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/widget/.

Source file: DateIndexer.java

  17 
vote

public DateIndexer(Context context,Cursor cursor,int sortedColumnIndex){
  mCursor=cursor;
  mColumnIndex=sortedColumnIndex;
  mIntFormat=new SimpleDateFormat("yyyyDDD");
  GregorianCalendar calendar=new GregorianCalendar();
  mCursor.moveToFirst();
  long firstDateLong=mCursor.getLong(mColumnIndex);
  mCursor.moveToLast();
  long lastDateLong=mCursor.getLong(mColumnIndex);
  Calendar startDate=Calendar.getInstance();
  startDate.setTimeInMillis(lastDateLong);
  Calendar endDate=Calendar.getInstance();
  endDate.setTimeInMillis(firstDateLong);
  mSectionCount=daysBetween(startDate,endDate);
  mSections=new String[mSectionCount];
  mSectionDates=new int[mSectionCount];
  mSectionPositions=new int[mSectionCount];
  calendar.setTimeInMillis(firstDateLong);
  for (int i=0; i < mSectionCount; i++) {
    mSections[i]=Util.formatDate(context,calendar.getTimeInMillis());
    mSectionDates[i]=Integer.parseInt(mIntFormat.format(calendar.getTime()));
    mSectionPositions[i]=-1;
    calendar.add(GregorianCalendar.DATE,-1);
  }
}
 

Example 24

From project anode, under directory /src/net/haltcondition/anode/.

Source file: Usage.java

  17 
vote

public void setRollOver(String str) throws ParseException {
  Date d=dateParser.parse(str);
  rollOver=new GregorianCalendar();
  rollOver.setTime(d);
  rollOver.setLenient(true);
}
 

Example 25

From project aranea, under directory /admin-api/src/main/java/no/dusken/aranea/admin/control/.

Source file: EditPageController.java

  17 
vote

@Override protected Object formBackingObject(HttpServletRequest request){
  Page page=(Page)super.formBackingObject(request);
  if (page.getVisibleTo() == null) {
    Calendar cal=new GregorianCalendar();
    cal.add(GregorianCalendar.YEAR,1000);
    page.setVisibleTo(cal);
  }
  if (page.getVisibleFrom() == null) {
    page.setVisibleFrom(new GregorianCalendar());
  }
  return page;
}
 

Example 26

From project babel, under directory /src/babel/content/corpora/accessors/.

Source file: CrawlCorpusAccessor.java

  17 
vote

/** 
 * @param corpusDir
 * @param charset
 * @param from start date (inclusive)
 * @param to end date (exclusive)
 */
public CrawlCorpusAccessor(String corpusDir,String charset,Date from,Date to,boolean oneSentPerLine){
  super(oneSentPerLine);
  if (from == null || to == null || from.after(to)) {
    throw new IllegalArgumentException("Dates missing / bad");
  }
  (m_fromDate=new GregorianCalendar()).setTime(from);
  (m_toDate=new GregorianCalendar()).setTime(to);
  resetDays();
  resetFiles();
  m_encoding=charset;
  m_files=new FileList(corpusDir);
}
 

Example 27

From project Barcamp-Bangalore-Android-App, under directory /bcb_app/src/com/bangalore/barcamp/.

Source file: MessagesListAdapter.java

  17 
vote

public View getView(int position,View convertView,ViewGroup parent){
  ViewHolder holder;
  BCBUpdatesMessage message=getItem(position);
  if (convertView == null) {
    convertView=layoutInflaterService.inflate(listViewResource,null);
    holder=new ViewHolder();
    holder.text1=(TextView)convertView.findViewById(android.R.id.text1);
    holder.text2=(TextView)convertView.findViewById(android.R.id.text2);
    convertView.setTag(holder);
  }
 else   holder=(ViewHolder)convertView.getTag();
  if (holder.text1 != null) {
    GregorianCalendar time=new GregorianCalendar();
    time.setTimeInMillis(Long.parseLong(message.getTimestamp()));
    holder.text1.setText(DateFormat.format("dd MMM yyyy, h:mmaa",time));
  }
  if (holder.text2 != null) {
    holder.text2.setText(message.getMessage());
  }
  return convertView;
}
 

Example 28

From project CIShell, under directory /core/org.cishell.utilities/src/org/cishell/utilities/.

Source file: DateUtilities.java

  17 
vote

@Deprecated public static Date[] generateDaysBetweenDates(Date startDate,Date endDate){
  GregorianCalendar startDateCalendar=new GregorianCalendar(startDate.getYear() + 1900,startDate.getMonth(),startDate.getDate());
  GregorianCalendar endDateCalendar=new GregorianCalendar(endDate.getYear() + 1900,endDate.getMonth(),endDate.getDate());
  if (startDateCalendar.getTimeInMillis() > endDateCalendar.getTimeInMillis())   return new Date[0];
  ArrayList workingDaysBetweenDates=new ArrayList();
  GregorianCalendar currentCalendarForDateThatWeAreCalculating=(GregorianCalendar)startDateCalendar.clone();
  final Date actualEndDateAccordingToCalendar=endDateCalendar.getTime();
  boolean shouldKeepGeneratingDaysBetweenDates=true;
  while (shouldKeepGeneratingDaysBetweenDates) {
    Date currentCalculatedDate=currentCalendarForDateThatWeAreCalculating.getTime();
    workingDaysBetweenDates.add(currentCalculatedDate);
    currentCalendarForDateThatWeAreCalculating.add(Calendar.DATE,1);
    if ((currentCalculatedDate.getYear() == actualEndDateAccordingToCalendar.getYear()) && (currentCalculatedDate.getMonth() == actualEndDateAccordingToCalendar.getMonth()) && (currentCalculatedDate.getDate() == actualEndDateAccordingToCalendar.getDate())) {
      shouldKeepGeneratingDaysBetweenDates=false;
    }
  }
  Date[] finalDaysBetweenDates=new Date[workingDaysBetweenDates.size()];
  return (Date[])workingDaysBetweenDates.toArray(finalDaysBetweenDates);
}
 

Example 29

From project coala, under directory /assemblies/coala/src/main/java/org/openehealth/coala/beans/.

Source file: ConsentBean.java

  17 
vote

/** 
 * @param validFrom the validFrom to set
 */
public void setValidFrom(Date validFrom){
  if (validFrom != null) {
    Calendar cal=new GregorianCalendar();
    cal.setTime(validFrom);
    cal.add(Calendar.DAY_OF_MONTH,1);
    this.validFrom=cal.getTime();
  }
 else {
    this.validFrom=validFrom;
  }
}
 

Example 30

From project cp-openrdf-utils, under directory /core/src/com/clarkparsia/openrdf/util/.

Source file: ResourceBuilder.java

  17 
vote

public ResourceBuilder addProperty(URI theProperty,Date theValue){
  if (theValue != null) {
    GregorianCalendar c=new GregorianCalendar();
    c.setTime(theValue);
    try {
      return addProperty(theProperty,mGraph.getValueFactory().createLiteral(DatatypeFactory.newInstance().newXMLGregorianCalendar(c).toXMLFormat(),XMLSchema.DATE));
    }
 catch (    DatatypeConfigurationException e) {
      throw new IllegalArgumentException(e);
    }
  }
 else {
    return this;
  }
}
 

Example 31

From project data-bus, under directory /databus-core/src/main/java/com/inmobi/databus/utils/.

Source file: CalendarHelper.java

  17 
vote

public static String getCurrentMinute(){
  Calendar calendar;
  calendar=new GregorianCalendar();
  String minute=Integer.toString(calendar.get(Calendar.MINUTE));
  return minute;
}
 

Example 32

From project demoiselle-contrib, under directory /demoiselle-primefaces/src/main/java/br/gov/frameworkdemoiselle/template/contrib/.

Source file: AbstractListPageBean.java

  17 
vote

@Override public List<T> getResultList(){
  if (this.resultList == null) {
    Calendar handleStart=new GregorianCalendar();
    this.resultList=handleResultList(getQueryConfig());
    Calendar handleStop=new GregorianCalendar();
    resultTime=(handleStop.getTimeInMillis() - handleStart.getTimeInMillis());
  }
  if (this.resultList != null)   this.resultSize=this.resultList.size();
  return this.resultList;
}
 

Example 33

From project DownloadProvider, under directory /src/com/mozillaonline/providers/downloads/ui/.

Source file: DownloadAdapter.java

  17 
vote

private Date getStartOfToday(){
  Calendar today=new GregorianCalendar();
  today.set(Calendar.HOUR_OF_DAY,0);
  today.set(Calendar.MINUTE,0);
  today.set(Calendar.SECOND,0);
  today.set(Calendar.MILLISECOND,0);
  return today.getTime();
}
 

Example 34

From project Ebento, under directory /src/mobisocial/bento/ebento/util/.

Source file: DateTimeUtils.java

  17 
vote

public static String getDateAndTimeWithShortFormat(boolean withYear,int year,int month,int day,int hour,int minute){
  SimpleDateFormat dateTimeFormat;
  if (withYear) {
    dateTimeFormat=new SimpleDateFormat("EEE, MMM d, yyyy h:mma");
  }
 else {
    dateTimeFormat=new SimpleDateFormat("EEE, MMM d, h:mma");
  }
  return dateTimeFormat.format(new GregorianCalendar(year,(month - 1),day,hour,minute).getTime());
}
 

Example 35

From project echo2, under directory /src/exampleapp/email/src/java/echo2example/email/faux/.

Source file: MessageGenerator.java

  17 
vote

public Date randomDate(){
  Calendar cal=new GregorianCalendar();
  cal.add(Calendar.DAY_OF_MONTH,randomInteger(MINIMUM_DATE_DELTA,MAXIMUM_DATE_DELTA));
  cal.add(Calendar.SECOND,-randomInteger(86400));
  return cal.getTime();
}
 

Example 36

From project ehour, under directory /eHour-common/src/main/java/net/rrm/ehour/report/criteria/.

Source file: UserCriteria.java

  17 
vote

/** 
 */
public UserCriteria(){
  onlyActiveProjects=true;
  onlyActiveCustomers=true;
  onlyActiveUsers=true;
  infiniteStartDate=false;
  infiniteEndDate=false;
  reportRange=DateUtil.getDateRangeForMonth(new GregorianCalendar());
  setCustomParameters(new HashMap<Object,Object>());
}
 

Example 37

From project emf4sw, under directory /bundles/com.emf4sw.rdf/src/com/emf4sw/rdf/operations/.

Source file: DatatypeConverter.java

  17 
vote

public static String toString(String datatype,Object object){
  if (datatype.equals("EDate") || datatype.equals("Date")) {
    final GregorianCalendar c=new GregorianCalendar();
    c.setTime(((Date)object));
    XMLGregorianCalendar date=null;
    try {
      date=DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
    }
 catch (    DatatypeConfigurationException e) {
      e.printStackTrace();
    }
    if (date != null) {
      return date.toXMLFormat();
    }
  }
 else   if (datatypes.containsKey(datatype)) {
    return EcoreFactory.eINSTANCE.convertToString(datatypes.get(datatype),object);
  }
  return object.toString();
}
 

Example 38

From project apps-for-android, under directory /Photostream/src/com/google/android/photostream/.

Source file: CheckUpdateService.java

  16 
vote

static void schedule(Context context){
  final Intent intent=new Intent(context,CheckUpdateService.class);
  final PendingIntent pending=PendingIntent.getService(context,0,intent,0);
  Calendar c=new GregorianCalendar();
  c.add(Calendar.DAY_OF_YEAR,1);
  c.set(Calendar.HOUR_OF_DAY,0);
  c.set(Calendar.MINUTE,0);
  c.set(Calendar.SECOND,0);
  c.set(Calendar.MILLISECOND,0);
  final AlarmManager alarm=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  alarm.cancel(pending);
  if (DEBUG) {
    alarm.setRepeating(AlarmManager.ELAPSED_REALTIME,SystemClock.elapsedRealtime(),30 * 1000,pending);
  }
 else {
    alarm.setRepeating(AlarmManager.RTC,c.getTimeInMillis(),UPDATES_CHECK_INTERVAL,pending);
  }
}
 

Example 39

From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/casemodule/.

Source file: Case.java

  16 
vote

/** 
 * Convert the Java timezone ID to the "formatted" string that can be accepted by the C/C++ code. Example: "America/New_York" converted to "EST5EDT", etc
 * @param timezoneID
 * @return
 */
public static String convertTimeZone(String timezoneID){
  String result="";
  TimeZone zone=TimeZone.getTimeZone(timezoneID);
  int offset=zone.getRawOffset() / 1000;
  int hour=offset / 3600;
  int min=(offset % 3600) / 60;
  DateFormat dfm=new SimpleDateFormat("z");
  dfm.setTimeZone(zone);
  boolean hasDaylight=zone.useDaylightTime();
  String first=dfm.format(new GregorianCalendar(2010,1,1).getTime()).substring(0,3);
  String second=dfm.format(new GregorianCalendar(2011,6,6).getTime()).substring(0,3);
  int mid=hour * -1;
  result=first + Integer.toString(mid);
  if (min != 0) {
    result=result + ":" + Integer.toString(min);
  }
  if (hasDaylight) {
    result=result + second;
  }
  return result;
}
 

Example 40

From project CCR-Validator, under directory /src/main/java/org/openhealthdata/validator/.

Source file: ValidationManager.java

  16 
vote

private ValidationResult validate(Object xml,String fileName){
  KnowledgeBase kbase=kbaseManager.getKnowledgeBase();
  ValidationResultManager valResMan=new BaseValidationManager();
  ValidationResult result=new ValidationResult();
  result.setDisclaimer("This validation test provides no warranty that all constraints were checked for given " + "profiles.  Additional testing may be required. Any issues should be reported to testing entity.");
  result.setFileTested(fileName);
  valResMan.setResult(result);
  try {
    result.setTimestamp(DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar()));
  }
 catch (  DatatypeConfigurationException e) {
    logger.log(Level.SEVERE,"Error creating XML datetime type",e);
    e.printStackTrace();
  }
  Collection<KnowledgePackage> pkgs=kbase.getKnowledgePackages();
  logger.log(Level.INFO,"Pkg list: " + pkgs.size());
  StatefulKnowledgeSession ksession=kbase.newStatefulKnowledgeSession();
  List<Rule> rules=new ArrayList<Rule>();
  for (  KnowledgePackage kpackage : kbase.getKnowledgePackages()) {
    rules.addAll(kpackage.getRules());
  }
  result.getRules().getRule().addAll(getRuleTypes(rules));
  ksession.setGlobal("val_result",valResMan);
  ksession.insert(xml);
  ksession.insert(ccrSchVal);
  ksession.fireAllRules();
  ksession.dispose();
  ValidationResult vr=valResMan.getResult();
  return vr;
}
 

Example 41

From project cidb, under directory /patient-update-listeners/src/main/java/edu/toronto/cs/cidb/listeners/.

Source file: PatientBirthdateUpdater.java

  16 
vote

@Override public void onEvent(Event event,Object source,Object data){
  XWikiDocument doc=(XWikiDocument)source;
  BaseObject patientRecordObj=doc.getXObject(new DocumentReference(doc.getDocumentReference().getRoot().getName(),"ClinicalInformationCode","PatientClass"));
  if (patientRecordObj == null) {
    return;
  }
  String targetPropertyName="date_of_birth";
  int year=getParameter("date_of_birth_year",patientRecordObj.getNumber());
  int month=getParameter("date_of_birth_month",patientRecordObj.getNumber());
  int day=getParameter("date_of_birth_day",patientRecordObj.getNumber());
  if (year == -1 || month == -1) {
    return;
  }
  if (day <= 0) {
    day=1;
  }
  Date birthdate=patientRecordObj.getDateValue(targetPropertyName);
  Date newBirthdate=new GregorianCalendar(year,month,day).getTime();
  if (!newBirthdate.equals(birthdate)) {
    patientRecordObj.setDateValue(targetPropertyName,newBirthdate);
  }
}
 

Example 42

From project Common-Sense-Net-2, under directory /RealFarm/src/com/commonsensenet/realfarm/.

Source file: AdviceActivity.java

  16 
vote

private void makeAudioSituation(AdviceSituationItem situationItem){
  String audioSequence=situationItem.getAdvice().getAudioSequence();
  int severity=situationItem.getRecommendation().getSeverity();
  String dataCollectionDate=situationItem.getRecommendation().getDataCollectionDate();
  List<Plot> plotList=mDataProvider.getPlotsByUserId(Global.userId);
  int plotNumber=0;
  for (int x=0; x < plotList.size(); x++) {
    if (plotList.get(x).getId() == situationItem.getPlotId()) {
      plotNumber=x;
      break;
    }
  }
  try {
    Date date=RealFarmProvider.sDateFormat.parse(dataCollectionDate);
    Calendar cal=new GregorianCalendar();
    cal.setTime(date);
    cal.get(Calendar.MONTH);
    cal.get(Calendar.YEAR);
    cal.get(Calendar.DAY_OF_MONTH);
    String[] audioPieces=audioSequence.split(",");
    playInteger(cal.get(Calendar.MONTH) + 1);
    playInteger(cal.get(Calendar.MONTH));
    playInteger(cal.get(Calendar.YEAR));
    addToSoundQueue(Integer.valueOf(audioPieces[0]));
    playInteger(plotNumber);
    addToSoundQueue(Integer.valueOf(audioPieces[1]));
    playInteger(severity);
    addToSoundQueue(Integer.valueOf(audioPieces[2]));
    playSound(true);
  }
 catch (  ParseException e) {
  }
}
 

Example 43

From project commons-io, under directory /src/test/java/org/apache/commons/io/.

Source file: FileUtilsTestCase.java

  16 
vote

public void testTouch() throws IOException {
  File file=new File(getTestDirectory(),"touch.txt");
  if (file.exists()) {
    file.delete();
  }
  assertTrue("Bad test: test file still exists",!file.exists());
  FileUtils.touch(file);
  assertTrue("FileUtils.touch() created file",file.exists());
  FileOutputStream out=new FileOutputStream(file);
  assertEquals("Created empty file.",0,file.length());
  out.write(0);
  out.close();
  assertEquals("Wrote one byte to file",1,file.length());
  long y2k=new GregorianCalendar(2000,0,1).getTime().getTime();
  boolean res=file.setLastModified(y2k);
  assertEquals("Bad test: set lastModified failed",true,res);
  assertEquals("Bad test: set lastModified set incorrect value",y2k,file.lastModified());
  long now=System.currentTimeMillis();
  FileUtils.touch(file);
  assertEquals("FileUtils.touch() didn't empty the file.",1,file.length());
  assertEquals("FileUtils.touch() changed lastModified",false,y2k == file.lastModified());
  assertEquals("FileUtils.touch() changed lastModified to more than now-3s",true,file.lastModified() >= now - 3000);
  assertEquals("FileUtils.touch() changed lastModified to less than now+3s",true,file.lastModified() <= now + 3000);
}
 

Example 44

From project Cours-3eme-ann-e, under directory /Java/FerryInpres/src/information_server/.

Source file: FreetaxStatsServer.java

  16 
vote

private static void statsDesc(Connection con,ObjectOutputStream obj_out,ObjectInputStream obj_in,FreetaxStatsDesc freetaxStatsDesc) throws SQLException, IOException {
  PreparedStatement instruc;
  int nbJours;
  if (freetaxStatsDesc.getSemaine() != null) {
    instruc=con.prepareStatement("SELECT jour_semaine AS jour, count " + "FROM stats_desc " + "WHERE categorie = ? "+ "  AND semaine = ?");
    instruc.setInt(2,freetaxStatsDesc.getSemaine().intValue());
    nbJours=7;
  }
 else {
    if (freetaxStatsDesc.getMois() == null) {
      freetaxStatsDesc.setMois(moisPrec());
    }
    instruc=con.prepareStatement("SELECT jour_mois AS jour, count " + "FROM stats_desc " + "WHERE categorie = ? "+ "  AND mois = ?");
    instruc.setInt(2,freetaxStatsDesc.getMois().intValue());
    Calendar cal=new GregorianCalendar();
    cal.set(Calendar.MONTH,freetaxStatsDesc.getMois());
    nbJours=cal.getActualMaximum(Calendar.DAY_OF_MONTH);
  }
  instruc.setString(1,freetaxStatsDesc.getCategorie());
  ResultSet rs=instruc.executeQuery();
  int[] ventes=new int[nbJours];
  while (rs.next()) {
    ventes[rs.getInt("jour") - 1]=rs.getInt("count");
  }
  Number[] ventesInteger=new Integer[nbJours];
  int i=0;
  for (  int v : ventes) {
    ventesInteger[i]=v;
    i++;
  }
  double moyenne=Statistics.calculateMean(ventesInteger);
  double ecartType=Statistics.getStdDev(ventesInteger);
  Integer mode=null;
  for (  int v : ventes) {
    if (mode == null || v > mode.intValue())     mode=v;
  }
  obj_out.writeObject(new FreetaxStatsDescReponse(ventes,moyenne,mode.intValue(),ecartType));
  obj_out.flush();
}
 

Example 45

From project CoursesPortlet, under directory /courses-portlet-api/src/main/java/org/jasig/portlet/courses/model/xml/.

Source file: TermListWrapper.java

  16 
vote

public Term getCurrentTerm(){
  Term bestDateMatch=null;
  int bestDist=Integer.MAX_VALUE;
  final int currentYear=new GregorianCalendar().get(Calendar.YEAR);
  for (  Term term : getTerms()) {
    if (term.isCurrent()) {
      return term;
    }
    final BigInteger termYear=term.getYear();
    if (termYear != null) {
      if (bestDateMatch == null) {
        bestDateMatch=term;
        bestDist=Math.abs(termYear.intValue() - currentYear);
      }
 else {
        final int dist=Math.abs(termYear.intValue() - currentYear);
        if (dist < bestDist) {
          bestDateMatch=term;
        }
      }
    }
  }
  return bestDateMatch;
}
 

Example 46

From project dreamDroid, under directory /src/net/reichholf/dreamdroid/fragment/.

Source file: ScreenShotFragment.java

  16 
vote

/** 
 */
@SuppressWarnings("unchecked") protected void reload(){
  ArrayList<NameValuePair> params=new ArrayList<NameValuePair>();
switch (mType) {
case (TYPE_OSD):
    params.add(new BasicNameValuePair("o",""));
  params.add(new BasicNameValuePair("n",""));
break;
case (TYPE_VIDEO):
params.add(new BasicNameValuePair("v",""));
break;
case (TYPE_ALL):
break;
}
switch (mFormat) {
case (FORMAT_JPG):
params.add(new BasicNameValuePair("format","jpg"));
break;
case (FORMAT_PNG):
params.add(new BasicNameValuePair("format","png"));
break;
}
params.add(new BasicNameValuePair("r",String.valueOf(mSize)));
if (mFilename == null) {
long ts=(new GregorianCalendar().getTimeInMillis()) / 1000;
mFilename="/tmp/dreamDroid-" + ts;
}
params.add(new BasicNameValuePair("filename",mFilename));
cancelTaskIfRunning();
mGetScreenshotTask=new GetScreenshotTask();
mGetScreenshotTask.execute(params);
}
 

Example 47

From project dungbeetle, under directory /src/edu/stanford/mobisocial/dungbeetle/util/.

Source file: RelativeDate.java

  16 
vote

/** 
 * This method returns a String representing the relative date by comparing the Calendar being passed in to the date / time that it is right now.
 * @param Calendar calendar
 * @return String representing the relative date
 */
public static String getRelativeDate(Calendar calendar){
  Calendar now=GregorianCalendar.getInstance();
  int years=calendar.get(Calendar.YEAR) - now.get(Calendar.YEAR);
  int months=calendar.get(Calendar.MONTH) - now.get(Calendar.MONTH);
  int days=calendar.get(Calendar.DAY_OF_MONTH) - now.get(Calendar.DAY_OF_MONTH);
  int hours=calendar.get(Calendar.HOUR_OF_DAY) - now.get(Calendar.HOUR_OF_DAY);
  int minutes=calendar.get(Calendar.MINUTE) - now.get(Calendar.MINUTE);
  int seconds=calendar.get(Calendar.SECOND) - now.get(Calendar.SECOND);
  return computeRelativeDate(calendar,years,months,days,hours,minutes,seconds);
}
 

Example 48

From project accounted4, under directory /accounted4/stock-quote/stock-quote-tmx/src/main/java/com/accounted4/stockquote/tmx/.

Source file: Option.java

  15 
vote

/** 
 * Assume ZERO prices as indicators of unknown values
 */
public Option(OptionType optionType,String symbol,GregorianCalendar expiryDate,BigDecimal strikePrice,BigDecimal bidPrice,BigDecimal askPrice,BigDecimal lastPrice){
  this.optionType=optionType;
  this.symbol=symbol;
  this.expiryDate=expiryDate;
  this.strikePrice=strikePrice;
  this.bidPrice=bidPrice;
  this.askPrice=askPrice;
  this.lastPrice=lastPrice;
}
 

Example 49

From project agile, under directory /agile-storage/src/main/java/org/headsupdev/agile/storage/.

Source file: DurationWorkedUtil.java

  15 
vote

public static Duration totalWorkedForDay(Issue issue,Date date){
  Calendar cal=GregorianCalendar.getInstance();
  cal.setTime(date);
  double total=0d;
  Calendar cal2=GregorianCalendar.getInstance();
  for (  DurationWorked worked : issue.getTimeWorked()) {
    if (worked.getDay() == null || worked.getUpdatedRequired() == null) {
      continue;
    }
    cal2.setTime(worked.getDay());
    if (cal.get(Calendar.DATE) == cal2.get(Calendar.DATE) && cal.get(Calendar.MONTH) == cal2.get(Calendar.MONTH) && cal.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)) {
      if (worked.getWorked() != null) {
        total+=worked.getWorked().getHours();
      }
    }
  }
  return new Duration(total);
}
 

Example 50

From project agraph-java-client, under directory /src/test/stress/.

Source file: Events.java

  15 
vote

public static void trace(String format,Object... values){
  StringBuilder sb=new StringBuilder();
  Formatter formatter=new Formatter(sb);
  if (Defaults.LOG == Defaults.LOGT.ALL) {
    formatter.format("%s [%2$tF %2$tT.%2$tL]: ",Thread.currentThread().getName(),GregorianCalendar.getInstance());
  }
 else   if (Defaults.LOG == Defaults.LOGT.ELAPSED) {
    formatter.format("%s [%d]: ",Thread.currentThread().getName(),(System.currentTimeMillis() - START));
  }
 else   if (Defaults.LOG == Defaults.LOGT.NOTIME) {
    formatter.format("%s: ",Thread.currentThread().getName());
  }
  formatter.format(format,values);
  System.out.println(sb.toString());
}
 

Example 51

From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/sqljep/function/.

Source file: OracleTimestampFormat.java

  15 
vote

public void parse(Calendar cal,DateFormatSymbols symb,String source,ParsePosition pos) throws java.text.ParseException {
  int i=pos.getIndex();
  String t=source.substring(i,i + 4);
  if (toString().equals(t.toUpperCase())) {
    pos.setIndex(i + 4);
    cal.set(ERA,GregorianCalendar.BC);
  }
 else   if (t.toUpperCase().equals("A.D.")) {
    pos.setIndex(i + 4);
    cal.set(ERA,GregorianCalendar.AD);
  }
 else {
    throw new java.text.ParseException("",0);
  }
}
 

Example 52

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/provider/.

Source file: BooksStore.java

  15 
vote

public static Book fromCursor(Cursor c){
  final Book book=new Book();
  book.mInternalId=c.getString(c.getColumnIndexOrThrow(INTERNAL_ID));
  book.mEan=c.getString(c.getColumnIndexOrThrow(EAN));
  book.mIsbn=c.getString(c.getColumnIndexOrThrow(ISBN));
  book.mTitle=c.getString(c.getColumnIndexOrThrow(TITLE));
  Collections.addAll(book.mAuthors,c.getString(c.getColumnIndexOrThrow(AUTHORS)).split(", "));
  book.mPublisher=c.getString(c.getColumnIndexOrThrow(PUBLISHER));
  book.mDescriptions.add(new Description("",c.getString(c.getColumnIndexOrThrow(REVIEWS))));
  book.mPages=c.getInt(c.getColumnIndexOrThrow(PAGES));
  final Calendar calendar=GregorianCalendar.getInstance();
  calendar.setTimeInMillis(c.getLong(c.getColumnIndexOrThrow(LAST_MODIFIED)));
  book.mLastModified=calendar;
  final SimpleDateFormat format=new SimpleDateFormat("MMMM yyyy");
  try {
    book.mPublicationDate=format.parse(c.getString(c.getColumnIndexOrThrow(PUBLICATION)));
  }
 catch (  ParseException e) {
  }
  book.mDetailsUrl=c.getString(c.getColumnIndexOrThrow(DETAILS_URL));
  book.mImages.put(ImageSize.TINY,c.getString(c.getColumnIndexOrThrow(TINY_URL)));
  return book;
}
 

Example 53

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: DataUsageListener.java

  15 
vote

private void initialize(){
  mThrottleManager=(ThrottleManager)mContext.getSystemService(Context.THROTTLE_SERVICE);
  mStart=GregorianCalendar.getInstance();
  mEnd=GregorianCalendar.getInstance();
  mFilter=new IntentFilter();
  mFilter.addAction(ThrottleManager.THROTTLE_POLL_ACTION);
  mFilter.addAction(ThrottleManager.THROTTLE_ACTION);
  mFilter.addAction(ThrottleManager.POLICY_CHANGED_ACTION);
  mReceiver=new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
      String action=intent.getAction();
      if (ThrottleManager.THROTTLE_POLL_ACTION.equals(action)) {
        updateUsageStats(intent.getLongExtra(ThrottleManager.EXTRA_CYCLE_READ,0),intent.getLongExtra(ThrottleManager.EXTRA_CYCLE_WRITE,0),intent.getLongExtra(ThrottleManager.EXTRA_CYCLE_START,0),intent.getLongExtra(ThrottleManager.EXTRA_CYCLE_END,0));
      }
 else       if (ThrottleManager.POLICY_CHANGED_ACTION.equals(action)) {
        updatePolicy();
      }
 else       if (ThrottleManager.THROTTLE_ACTION.equals(action)) {
        updateThrottleRate(intent.getIntExtra(ThrottleManager.EXTRA_THROTTLE_LEVEL,-1));
      }
    }
  }
;
}
 

Example 54

From project Application-Builder, under directory /src/main/java/org/silverpeas/applicationbuilder/.

Source file: Log.java

  15 
vote

public static void close(){
  if (!logOutputIsScreen) {
    out.println("------------------------------");
    out.println("Application Builder Log File - END " + GregorianCalendar.getInstance().getTime());
    out.close();
  }
}
 

Example 55

From project beanvalidation-tck, under directory /tests/src/main/java/org/hibernate/beanvalidation/tck/tests/constraints/builtinconstraints/.

Source file: BuiltinConstraintsTest.java

  15 
vote

@Test @SpecAssertions({@SpecAssertion(section="6",id="a"),@SpecAssertion(section="6",id="m")}) public void testPastConstraint(){
  Validator validator=TestUtil.getValidatorUnderTest();
  PastDummyEntity dummy=new PastDummyEntity();
  Set<ConstraintViolation<PastDummyEntity>> constraintViolations=validator.validate(dummy);
  assertCorrectNumberOfViolations(constraintViolations,0);
  Calendar cal=GregorianCalendar.getInstance();
  cal.add(Calendar.YEAR,1);
  dummy.calendar=cal;
  dummy.date=cal.getTime();
  constraintViolations=validator.validate(dummy);
  assertCorrectNumberOfViolations(constraintViolations,2);
  assertCorrectPropertyPaths(constraintViolations,"date","calendar");
  cal.add(Calendar.YEAR,-2);
  dummy.calendar=cal;
  dummy.date=cal.getTime();
  constraintViolations=validator.validate(dummy);
  assertCorrectNumberOfViolations(constraintViolations,0);
}
 

Example 56

From project Diver, under directory /ca.uvic.chisel.logging.eclipse/src/ca/uvic/chisel/logging/eclipse/internal/network/.

Source file: UploadJob.java

  15 
vote

public static long today(){
  long currentTime=System.currentTimeMillis();
  Calendar cal=GregorianCalendar.getInstance();
  cal.setTimeInMillis(currentTime);
  cal.set(cal.get(Calendar.YEAR),cal.get(Calendar.MONTH),cal.get(Calendar.DAY_OF_MONTH),0,0,0);
  long calendarTime=cal.getTimeInMillis();
  return calendarTime;
}
 

Example 57

From project droolsjbpm-integration, under directory /drools-camel/src/main/java/org/drools/camel/component/.

Source file: FastCloner.java

  15 
vote

/** 
 * registers a std set of fast cloners.
 */
protected void registerFastCloners(){
  this.fastCloners.put(GregorianCalendar.class,new FastClonerCalendar());
  this.fastCloners.put(ArrayList.class,new FastClonerArrayList());
  this.fastCloners.put(Arrays.asList(new Object[]{""}).getClass(),new FastClonerArrayList());
  this.fastCloners.put(LinkedList.class,new FastClonerLinkedList());
  this.fastCloners.put(HashSet.class,new FastClonerHashSet());
  this.fastCloners.put(HashMap.class,new FastClonerHashMap());
  this.fastCloners.put(TreeMap.class,new FastClonerTreeMap());
}