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


Python util.Date方法代码示例

本文整理汇总了Python中java.util.Date方法的典型用法代码示例。如果您正苦于以下问题:Python util.Date方法的具体用法?Python util.Date怎么用?Python util.Date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util的用法示例。


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

示例1: createClient

# 需要导入模块: from java import util [as 别名]
# 或者: from java.util import Date [as 别名]
def createClient(self, registerRequest, client, configurationAttributes):

        print "Casa client registration. CreateClient method"
        redirectUris = client.getRedirectUris()
        print "Casa client registration. Redirect Uris: %s" % redirectUris

        credManagerClient = False
        for redirectUri in redirectUris:
            if self.clientRedirectUrisSet.contains(redirectUri):
                credManagerClient = True
                break
        
        if not credManagerClient:
            return True

        print "Casa client registration. Client is Gluu Casa"
        self.setClientScopes(client, configurationAttributes.get("scopes"))
        #Extend client lifetime for one year
        cal=GregorianCalendar()
        cal.add(1,10)
        client.setClientSecretExpiresAt(Date(cal.getTimeInMillis()))
        client.setTrustedClient(True)
        return True

    # Update client entry before persistent it
    #   registerRequest is org.gluu.oxauth.client.RegisterRequest
    #   client is org.gluu.oxauth.model.registration.Client
    #   configurationAttributes is java.util.Map<String, SimpleCustomProperty> 
开发者ID:GluuFederation,项目名称:community-edition-setup,代码行数:30,代码来源:Casa.py

示例2: new_unauthenticated_session

# 需要导入模块: from java import util [as 别名]
# 或者: from java.util import Date [as 别名]
def new_unauthenticated_session(self,user,client):
        sessionIdService = CdiUtil.bean(SessionIdService)
        authDate = Date()
        sid_attrs = HashMap()
        sid_attrs.put(Constants.AUTHENTICATED_USER,user.getUserId())
        sid_attrs.put(self.clientIdSessionParamName,client.getClientId())
        sessionId = sessionIdService.generateUnauthenticatedSessionId(user.getDn(),authDate,SessionIdState.UNAUTHENTICATED,sid_attrs,True)
        print "Super-Gluu-RO. Generated session id. DN: '%s'" % sessionId.getDn()
        return sessionId 
开发者ID:GluuFederation,项目名称:community-edition-setup,代码行数:11,代码来源:super_gluu_ro.py

示例3: esper_bridge

# 需要导入模块: from java import util [as 别名]
# 或者: from java.util import Date [as 别名]
def esper_bridge(event):
    event_type = event.getProperty('type')
    if event_type == 'ItemStateEvent':
        event_payload = json.loads(event.getProperty('payload'))
        event_topic = event.getProperty('topic').split('/')
        item_name = event_topic[2]
        record = {
            "type": event_type,
            "time": Date(),
            "name": item_name,
            "state": event_payload['value']
        }
        runtime.sendEvent(record, record['type'])
    elif event_type == 'ItemStateChangedEvent':
        event_payload = json.loads(event.getProperty('payload'))
        event_topic = event.getProperty('topic').split('/')
        item_name = event_topic[2]
        record = {
            "type": event_type,
            "time": Date(),
            "name": item_name,
            "previous_state": event_payload['oldValue'],
            "state": event_payload['value']
        }
        runtime.sendEvent(record, record['type'])
    elif event_type == 'ItemCommandEvent':
        event_payload = json.loads(event.getProperty('payload'))
        event_topic = event.getProperty('topic').split('/')
        item_name = event_topic[2]
        record = {
            "type": event_type,
            "time": Date(),
            "name": item_name,
            "command": event_payload['value'],
        }
        runtime.sendEvent(record, record['type']) 
开发者ID:openhab-scripters,项目名称:openhab-helper-libraries,代码行数:38,代码来源:000_Esper.py

示例4: calendar

# 需要导入模块: from java import util [as 别名]
# 或者: from java.util import Date [as 别名]
def calendar(self):
        c = Calendar.getInstance()
        c.setTime(JDate())
        return c 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:6,代码来源:zxtest.py

示例5: test_str_doesnt_coerce_to_int

# 需要导入模块: from java import util [as 别名]
# 或者: from java.util import Date [as 别名]
def test_str_doesnt_coerce_to_int(self):
        self.assertRaises(TypeError, Date, '99-01-01', 1, 1) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:4,代码来源:test_java_integration.py

示例6: test_comparable_delegation

# 需要导入模块: from java import util [as 别名]
# 或者: from java.util import Date [as 别名]
def test_comparable_delegation(self):
        first_file = File("a")
        first_date = Date(100)
        for a, b, c in [(first_file, File("b"), File("c")), (first_date, Date(1000), Date())]:
            self.assertTrue(a.compareTo(b) < 0)
            self.assertEquals(-1, cmp(a, b))
            self.assertTrue(a.compareTo(c) < 0)
            self.assertEquals(-1, cmp(a, c))
            self.assertEquals(0, a.compareTo(a))
            self.assertEquals(0, cmp(a, a))
            self.assertTrue(b.compareTo(a) > 0)
            self.assertEquals(1, cmp(b, a))
            self.assertTrue(c.compareTo(b) > 0)
            self.assertEquals(1, cmp(c, b))
            self.assertTrue(a < b)
            self.assertTrue(a <= a)
            self.assertTrue(b > a)
            self.assertTrue(c >= a)
            self.assertTrue(a != b)
            l = [b, c, a]
            self.assertEquals(a, min(l))
            self.assertEquals(c, max(l))
            l.sort()
            self.assertEquals([a, b, c], l)
        # Check that we fall back to the default comparison(class name) instead of using compareTo
        # on non-Comparable types
        self.assertRaises(ClassCastException, first_file.compareTo, first_date)
        self.assertEquals(-1, cmp(first_file, first_date))
        self.assertTrue(first_file < first_date)
        self.assertTrue(first_file <= first_date)
        self.assertTrue(first_date > first_file)
        self.assertTrue(first_date >= first_file) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:34,代码来源:test_java_integration.py

示例7: test_java_serialization

# 需要导入模块: from java import util [as 别名]
# 或者: from java.util import Date [as 别名]
def test_java_serialization(self):
        date_list = [Date(), Date()]
        self.assertEqual(date_list, roundtrip_serialization(date_list)) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:5,代码来源:test_java_integration.py

示例8: to_java_zoneddatetime

# 需要导入模块: from java import util [as 别名]
# 或者: from java.util import Date [as 别名]
def to_java_zoneddatetime(value):
    """
    Converts any of the supported date types to ``java.time.ZonedDateTime``. If
    ``value`` does not have timezone information, the system default will be
    used.

    Examples:
        .. code-block::

            java_time = to_java_zoneddatetime(items["date_item"])

    Args:
        value: the value to convert

    Returns:
        java.time.ZonedDateTime: the converted value

    Raises:
        TypeError: if the type of ``value`` is not supported by this module
    """
    if isinstance(value, ZonedDateTime):
        return value
    timezone_id = ZoneId.systemDefault()
    # java.time.LocalDateTime
    if isinstance(value, LocalDateTime):
        return value.atZone(timezone_id)
    # python datetime
    if isinstance(value, datetime.datetime):
        if value.tzinfo is not None:
            timezone_id = ZoneId.ofOffset("GMT", ZoneOffset.ofTotalSeconds(int(value.utcoffset().total_seconds())))
        return ZonedDateTime.of(
            value.year,
            value.month,
            value.day,
            value.hour,
            value.minute,
            value.second,
            value.microsecond * 1000,
            timezone_id
        )
    # java.util.Calendar
    if isinstance(value, Calendar):
        return ZonedDateTime.ofInstant(value.toInstant(), ZoneId.of(value.getTimeZone().getID()))
    # java.util.Date
    if isinstance(value, Date):
        return ZonedDateTime.ofInstant(value.toInstant(), ZoneId.ofOffset("GMT", ZoneOffset.ofHours(0 - value.getTimezoneOffset() / 60)))
    # Joda DateTime
    if isinstance(value, DateTime):
        return value.toGregorianCalendar().toZonedDateTime()
    # openHAB DateTimeType
    if isinstance(value, eclipseDateTime):
        return to_java_zoneddatetime(value.calendar)
    # openHAB 1.x DateTimeType
    if legacyDateTime and isinstance(value, legacyDateTime):
        return to_java_zoneddatetime(value.calendar)

    raise TypeError("Unknown type: {}".format(str(type(value)))) 
开发者ID:openhab-scripters,项目名称:openhab-helper-libraries,代码行数:59,代码来源:date.py


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