Python java.util.Date() Examples
The following are 16
code examples of java.util.Date().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
java.util
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: Casa.py From community-edition-setup with MIT License | 5 votes |
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>
Example #2
Source File: super_gluu_ro.py From community-edition-setup with MIT License | 5 votes |
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
Example #3
Source File: 000_Esper.py From openhab-helper-libraries with Eclipse Public License 1.0 | 5 votes |
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'])
Example #4
Source File: zxtest.py From medicare-demo with Apache License 2.0 | 5 votes |
def calendar(self): c = Calendar.getInstance() c.setTime(JDate()) return c
Example #5
Source File: test_java_integration.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_str_doesnt_coerce_to_int(self): self.assertRaises(TypeError, Date, '99-01-01', 1, 1)
Example #6
Source File: test_java_integration.py From medicare-demo with Apache License 2.0 | 5 votes |
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)
Example #7
Source File: test_java_integration.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_java_serialization(self): date_list = [Date(), Date()] self.assertEqual(date_list, roundtrip_serialization(date_list))
Example #8
Source File: zxtest.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def calendar(self): c = Calendar.getInstance() c.setTime(JDate()) return c
Example #9
Source File: test_java_integration.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_str_doesnt_coerce_to_int(self): self.assertRaises(TypeError, Date, '99-01-01', 1, 1)
Example #10
Source File: test_java_integration.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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)
Example #11
Source File: test_java_integration.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_java_serialization(self): date_list = [Date(), Date()] self.assertEqual(date_list, roundtrip_serialization(date_list))
Example #12
Source File: zxtest.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def calendar(self): c = Calendar.getInstance() c.setTime(JDate()) return c
Example #13
Source File: test_java_integration.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_str_doesnt_coerce_to_int(self): self.assertRaises(TypeError, Date, '99-01-01', 1, 1)
Example #14
Source File: test_java_integration.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)
Example #15
Source File: test_java_integration.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_java_serialization(self): date_list = [Date(), Date()] self.assertEqual(date_list, roundtrip_serialization(date_list))
Example #16
Source File: date.py From openhab-helper-libraries with Eclipse Public License 1.0 | 4 votes |
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))))