当前位置: 首页>>代码示例>>Python>>正文


Python text.SimpleDateFormat类代码示例

本文整理汇总了Python中java.text.SimpleDateFormat的典型用法代码示例。如果您正苦于以下问题:Python SimpleDateFormat类的具体用法?Python SimpleDateFormat怎么用?Python SimpleDateFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SimpleDateFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __newDoc

    def __newDoc(self):
        self.oid = self.object.getId()
        self.pid = self.payload.getId()
        metadataPid = self.params.getProperty("metaPid", "DC")

        self.utils.add(self.index, "storage_id", self.oid)
        if self.pid == metadataPid:
            self.itemType = "object"
        else:
            self.oid += "/" + self.pid
            self.itemType = "datastream"
            self.utils.add(self.index, "identifier", self.pid)

        self.utils.add(self.index, "id", self.oid)
        self.utils.add(self.index, "item_type", self.itemType)
        self.utils.add(self.index, "last_modified", self.last_modified)
        self.utils.add(self.index, "harvest_config", self.params.getProperty("jsonConfigOid"))
        self.utils.add(self.index, "harvest_rules",  self.params.getProperty("rulesOid"))

        self.item_security = []
        self.owner = self.params.getProperty("owner", "guest")
        formatter = SimpleDateFormat('yyyyMMddHHmmss')
        self.params.setProperty("last_modified", formatter.format(Date()))        
        self.utils.add(self.index, "date_object_created", self.params.getProperty("date_object_created"))
        self.params.setProperty("date_object_modified", time.strftime("%Y-%m-%dT%H:%M:%SZ", time.localtime()) )
        self.utils.add(self.index, "date_object_modified",  self.params.getProperty("date_object_modified"))
开发者ID:ozej8y,项目名称:redbox,代码行数:26,代码来源:dataset-rules.py

示例2: setupjob

def setupjob(job, args):
    """
    Set up a job to run on telemetry date ranges using data from HBase

    Telemetry jobs expect two arguments, startdate and enddate, both in yyyymmdd format.
    """

    import java.text.SimpleDateFormat as SimpleDateFormat
    import java.util.Calendar as Calendar
    import com.mozilla.hadoop.hbase.mapreduce.MultiScanTableMapReduceUtil as MSTMRU
    import com.mozilla.util.Pair

    if len(args) != 2:
        raise Exception("Usage: <startdate-YYYYMMDD> <enddate-YYYYMMDD>")

    sdf = SimpleDateFormat(dateformat)
    startdate = Calendar.getInstance()
    startdate.setTime(sdf.parse(args[0]))
    enddate = Calendar.getInstance()
    enddate.setTime(sdf.parse(args[1]))

    columns = [com.mozilla.util.Pair('data', 'json')]
    scans = MSTMRU.generateBytePrefixScans(startdate, enddate, dateformat,
                                           columns, 500, False)
    MSTMRU.initMultiScanTableMapperJob(
        'telemetry',
        scans,
        None, None, None, job)

    # inform HadoopDriver about the columns we expect to receive
    job.getConfiguration().set("org.mozilla.jydoop.hbasecolumns", "data:json");
开发者ID:smillaedler,项目名称:jydoop,代码行数:31,代码来源:telemetryutils.py

示例3: stringToDate

def stringToDate(value):
	"""
	Information about how to build your own date pattern is here:
	http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html
	"""
	dateFormat = SimpleDateFormat("dd MMM yyyy HH:mm")
	return dateFormat.parse(value)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:7,代码来源:import_converters.py

示例4: setMembershipTime

def setMembershipTime(session, groupName, memberName, enable_str=None, expire_str=None):
    """
    Set the expiration date for a group member.

    :param session:`The grouper session`
    :param groupName:`The fully qualified group name`
    :param memberName:`The fully qualified member name`
    :param enable_str:`The enable date/time in yyyy-mm-dd HH:MM:SS format`
    :param expire_str:`The expiration date/time in yyyy-mm-dd HH:MM:SS format`
    """
    sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
    if enable_str is not None:
        ts = sdf.parse(enable_str)
        enable_millis = ts.getTime()
    else:
        enable_millis = None
    if expire_str is not None:
        ts = sdf.parse(expire_str)
        expire_millis = ts.getTime()
    else:
        expire_millis = None
    grp = jython_grouper.getGroup(session, groupName) 
    memberships = grp.memberships.toArray()
    for m in memberships:
        member = m.member
        if member.name == memberName:
            m.enabledTimeDb = enable_millis
            m.disabledTimeDb = expire_millis
            m.update()
            return True
    else:
        return False
开发者ID:cwaldbieser,项目名称:grouper_jython_scripts,代码行数:32,代码来源:temporal.py

示例5: _parseDate

 def _parseDate(self, dateStr):
     for parsePattern in ["MM/dd/yyyy HH:mm:ss", "MM.dd.yyyy HH:mm:ss", "yyyyMMddHHmmss"]:
         try:
             logger.debug('Trying to parse date string %s with pattern %s' % (dateStr, parsePattern))
             dateFormat = SimpleDateFormat(parsePattern)
             return dateFormat.parse(dateStr)
         except:
             logger.warn('Failed parsing date %s with date format %s' % (dateStr, parsePattern))
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:8,代码来源:msexchange_win_shell.py

示例6: _parseStartDate

 def _parseStartDate(self, date):
     r'@types: str -> java.util.Date or None'
     try:
         dateFormat = SimpleDateFormat("HHmmss yyyyMMdd")
         return dateFormat.parse(date)
     except:
         logger.warnException('Failed to convert start date: %s'
                              ' to HHmmss yyyyMMdd' % date)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:8,代码来源:sap_abap_discoverer.py

示例7: parse_time

def parse_time(time):
    r'@types: str->java.util.Date or None'
    try:
        from java.text import SimpleDateFormat
        s = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
        return s.parse(time)
    except:
        logger.debug('Failed to parse time: %s' % time)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:8,代码来源:hana_sql_command.py

示例8: findTimestamp

 def findTimestamp (self, dateTup, timeTup):
     str_date = dateTup + " " + timeTup + " GMT"
     formatter = SimpleDateFormat("dd MMM yyyy HH:mm:ss z")
     p_date = formatter.parse(str_date)
     parsed_year = p_date.getYear()
     if parsed_year > 3000:
         print "parsed year is too large: " + str(parsed_year)
         return 0
     else:
         sc_tmstmp = Timestamp (p_date.getTime())
         return sc_tmstmp.getTime() / 1000
开发者ID:HauptmannEck,项目名称:oss-dataturbine,代码行数:11,代码来源:TwoWaySerialComm.py

示例9: createSimpleTask

def createSimpleTask(phaseId, taskTypeValue, title, propertyMap):
    parenttaskType = Type.valueOf(taskTypeValue)
    parentTask = parenttaskType.descriptor.newInstance("nonamerequired")
    parentTask.setTitle(title)
    sdf = SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
    for item in propertyMap:
        if item.lower().find("date") > -1:
            if propertyMap[item] is not None and len(propertyMap[item]) != 0:
                parentTask.setProperty(item,sdf.parse(propertyMap[item]))
        else:
            parentTask.setProperty(item,propertyMap[item])
    taskApi.addTask(phaseId,parentTask)
开发者ID:gpsolanki,项目名称:xlr-release-profile-plugin,代码行数:12,代码来源:LoadProfile.py

示例10: tail_logfile

def tail_logfile(log_file,from_time):
  from java.text import SimpleDateFormat
  import re
  
  pattern=re.compile("\[(.*)\]")
  formatter = SimpleDateFormat("dd/MMM/yy:H:m:s Z")
          
  for line in log_file[1].split('\n'):
    mymatch = pattern.match(line)
    if mymatch:
      timestamp=mymatch.group(1)
      timestamp_object = formatter.parse(timestamp)
      if date_compare(from_time,timestamp_object) == 'Less':
        print line
开发者ID:SmarterApp,项目名称:IM_OpenDJ,代码行数:14,代码来源:common.py

示例11: actionPerformed

	def actionPerformed(self,actionEvent):
		self.scl_long_tuneup_controller.getMessageTextField().setText("")	
		rightNow = Calendar.getInstance()
		date_format = SimpleDateFormat("MM.dd.yyyy")
		time_str = date_format.format(rightNow.getTime())				
		fc = JFileChooser(constants_lib.const_path_dict["XAL_XML_ACC_FILES_DIRS_PATH"])
		fc.setDialogTitle("Save SCL data into the SCL_new.xdxf file")
		fc.setApproveButtonText("Save")
		fl_filter = FileNameExtensionFilter("SCL Acc File",["xdxf",])
		fc.setFileFilter(fl_filter)
		fc.setSelectedFile(File("SCL_"+time_str+".xdxf"))		
		returnVal = fc.showOpenDialog(self.scl_long_tuneup_controller.linac_wizard_document.linac_wizard_window.frame)
		if(returnVal == JFileChooser.APPROVE_OPTION):
			fl_out = fc.getSelectedFile()
			fl_path = fl_out.getPath()
			if(fl_path.rfind(".xdxf") != (len(fl_path) - 5)):
				fl_out = File(fl_out.getPath()+".xdxf")	
			#---------prepare the XmlDataAdaptor 
			root_DA = XmlDataAdaptor.newEmptyDocumentAdaptor()
			scl_DA = root_DA.createChild("xdxf")	
			scl_DA.setValue("date",time_str)
			scl_DA.setValue("system","sns")
			scl_DA.setValue("version","2.0")
			#---- SCLMed	
			seq_name_arr = ["SCLMed","SCLHigh","HEBT1"]
			for seq_name in seq_name_arr:
				accl = self.scl_long_tuneup_controller.linac_wizard_document.accl
				seq = accl.findSequence(seq_name)
				cavs = seq.getAllNodesWithQualifier(AndTypeQualifier().and((OrTypeQualifier()).or(SCLCavity.s_strType)))
				quads = seq.getAllNodesWithQualifier(AndTypeQualifier().and((OrTypeQualifier()).or(Quadrupole.s_strType)))
				scl_seq_DA = scl_DA.createChild("sequence")
				scl_seq_DA.setValue("id",seq.getId())
				for quad in quads:
					node_DA = scl_seq_DA.createChild("node")
					node_DA.setValue("id",quad.getId())
					attr_DA = node_DA.createChild("attributes")
					field_DA = attr_DA.createChild("magnet")
					scl_quad_fields_dict_holder = self.scl_long_tuneup_controller.scl_long_tuneup_init_controller.scl_quad_fields_dict_holder
					field_DA.setValue("dfltMagFld",str(scl_quad_fields_dict_holder.quad_field_dict[quad]))
				for cav in cavs:
					node_DA = scl_seq_DA.createChild("sequence")
					node_DA.setValue("id",cav.getId())
					attr_DA = node_DA.createChild("attributes")
					rf_cav_DA = attr_DA.createChild("rfcavity")
					cav_wrappper = self.scl_long_tuneup_controller.getCav_WrapperForCavId(cav.getId())
					(amp,phase) =  (cav_wrappper.designAmp,cav_wrappper.designPhase)
					rf_cav_DA.setValue("amp",float("%8.5f"%amp))
					rf_cav_DA.setValue("phase",float("%8.3f"%phase))
			root_DA.writeTo(fl_out)		
开发者ID:kritha,项目名称:MyOpenXal,代码行数:49,代码来源:scl_long_tuneup_phase_analysis_cntrl_lib.py

示例12: __activate__

 def __activate__(self, context):
     self.auth = context["page"].authentication
     self.errorMsg = "" 
     self.request = context["request"]
     self.response = context["response"]
     self.fromDtTxt =  self.request.getParameter("from")
     self.toDtTxt = self.request.getParameter("to")
     self.reportName = self.request.getParameter("reportName")
     self.dateFormatter = SimpleDateFormat("d/M/yyyy")
     self.systemConfig = context["systemConfig"]
     if (self.fromDtTxt is None or self.toDtTxt is None):
         curCal = Calendar.getInstance()
         self.fromDtTxt =  "1/1/%s" % curCal.get(Calendar.YEAR)
         self.toDtTxt =  "%s/%s/%s" % (curCal.get(Calendar.DAY_OF_MONTH), curCal.get(Calendar.MONTH)+1,curCal.get(Calendar.YEAR))
     if (self.reportName is None):
         self.reportName = "Dashboard Report"
     if (self.auth.is_logged_in()):
         if (self.auth.is_admin()==True):
             self.action = self.request.getParameter("action") 
             if self.action == "export":
                 self.exportDashboard(context)
             else:
                 self.buildDashboard(context)
         else:
             self.errorMsg = "Requires Admin / Librarian / Reviewer access." 
     else:
         self.errorMsg = "Please login."
开发者ID:greg-pendlebury,项目名称:redbox,代码行数:27,代码来源:dashboard.py

示例13: setupjob

def setupjob(job, args):
    """
    Set up a job to run on a date range of directories.

    Jobs expect two arguments, startdate and enddate, both in yyyy-MM-dd format.
    """

    import java.text.SimpleDateFormat as SimpleDateFormat
    import java.util.Date as Date
    import java.util.Calendar as Calendar
    import com.mozilla.util.DateUtil as DateUtil
    import com.mozilla.util.DateIterator as DateIterator
    import org.apache.hadoop.mapreduce.lib.input.FileInputFormat as FileInputFormat
    import org.apache.hadoop.mapreduce.lib.input.SequenceFileAsTextInputFormat as MyInputFormat

    if len(args) != 3:
        raise Exception("Usage: <testpilot_study> <startdate-YYYY-MM-DD> <enddate-YYYY-MM-DD>")

    # use to collect up each date in the given range
    class MyDateIterator(DateIterator):
       def __init__(self):
          self._list = []
       def get(self):
          return self._list
       def see(self, aTime):
          self._list.append(aTime)

    sdf = SimpleDateFormat(dateformat)
    study = args[0]
    startdate = Calendar.getInstance()
    startdate.setTime(sdf.parse(args[1]))

    enddate = Calendar.getInstance()
    enddate.setTime(sdf.parse(args[2]))

    dates = MyDateIterator()

    DateUtil.iterateByDay(startdate.getTimeInMillis(), enddate.getTimeInMillis(), dates)

    paths = []
    for d in dates.get():
       paths.append(pathformat % (study, sdf.format(Date(d))))

    job.setInputFormatClass(MyInputFormat)
    FileInputFormat.setInputPaths(job, ",".join(paths));
    job.getConfiguration().set("org.mozilla.jydoop.mappertype", "TEXT")
开发者ID:bcolloran,项目名称:jydoop,代码行数:46,代码来源:testpilotutils.py

示例14: _parseDateString

def _parseDateString(installDateString):
    installationDateAsDate = None
    if installDateString:
        for format in ['yyyyMMdd', 'yyyyMMddHHmmss.SSSSSS-000', 'EEE dd MMM yyyy HH:mm:ss aa zzz']:
            if len(installDateString) == len(format):
                try:
                    from java.text import SimpleDateFormat
                    from java.util import TimeZone
                    dateFormatter = SimpleDateFormat(format)

                    dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT"))
                    installationDateAsDate = dateFormatter.parse(installDateString)
                except java.text.ParseException:
                    # could not parse date
                    # print 'could not parse' + installDateString + ' as ' + format
                    pass
    return installationDateAsDate
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:17,代码来源:hostresource.py

示例15: __init__

 def __init__(self, imp):
     '''Get the metadata from the given dm3 image.
     '''
     extractor = GatanMetadataExtractor(imp)
     self.exposure = extractor.getExposure()
     self.magnification = extractor.getMagnification()
     self.mag_factor = extractor.getActualMagnification() / self.magnification
     self.mag_unit = 'x'
     if not Double.isNaN(extractor.getEnergyloss()):
         self.energyloss = extractor.getEnergyloss()
     else:
         self.energyloss = 0
     self.date = extractor.getDateAndTime()
     date_formater = SimpleDateFormat('yyyyMMdd')
     self.date_string = date_formater.format(self.date)
     self.name = extractor.getName()
     self.prop_dict = {}
开发者ID:m-entrup,项目名称:EFTEMj,代码行数:17,代码来源:Gatan_Renamer.py


注:本文中的java.text.SimpleDateFormat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。