My php code :
echo time();
-----> 1427313418
My java (android) code :
String current_in_sec = (System.currentTimeMillis()/1000)+""; // to convert it to seconds.
Log.i("Log",current_in_sec);
----> 1427306783
Notice in php : 1427313783 , vs java 1427306418
I know that php returns time in seconds , while java returns time in millies , so I devided Java result by 1000 .
As you can see , the differences is not about milli seconds , it seems they are very different ( about 2 hours maybe );
And in php I used this :
date_default_timezone_set('UTC');
But it doesn't make any difference ;
Any guess ?
Hint :
I tried not to divide Java result by 1000 , here is the result :
String current_in_sec = (System.currentTimeMillis())+"";
Log.i("Log",current_in_sec);
----> 1427307978601
As you can see again 1427307978601 , The BOLD part is far different from php result;
This tests are in my Laptop:
myLaptop->Android studio->genymotion
myLaptop->(PHP+Apache)->SublimeText
Genymotion emulator is set to wrong timezone. Go to the Android settings, and set correct location/timezone. I had the same problem before.
Also, set it manually, not from internet.
Related
I have a requirement to schedule a job in AWS CloudWatch events to be run once in every two days. I am using the below expression but getting a error Parameter ScheduleExpression is not valid
cron(0 0 */2 * ? *)
The below is the java code,
String cronExpression = "cron(0 0 */2 * ? *)"
PutRuleRequest request = new PutRuleRequest();
request
.withName(eventName)
.withRoleArn("arn:aws:iam::****")
.withScheduleExpression(cronExpression)
.withState(RuleState.ENABLED);
PutRuleResult result = cloudwatchConfig.cloudwatch().putRule(request);
cron(0 0 1/2 * ? *)
You can verify here.
If you put your syntax into cloudwatch, it too will report the same error you are seeing in the terraform,but fix it simple
cron(0 0 1-31/2 * ? *)
The explanation for each field is here: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html
1-31 covers all the possible number of days in a month
I'm trying to select current date from the calendar on this website "www.makemytrip.com".
Using these 2 lines of code:
driver.findElement(By.xpath("//label[#for='departure']")).click();
To open the calendar and to select date:
driver.findElement(By.cssSelector(".DayPicker-Day.DayPicker-Day--selected.DayPicker-Day--today")).click();
The first one is working fine as it opens up the calendar but cssSelector is not responding. I've tried various variations but still it remains unresponsive.
Try this xpath strategy:
//div[#class='DayPicker-Day DayPicker-Day--today']
Now, i write in python, so you may translate my code to Java, since most of it remains same.
time.sleep (Thread.sleep in Java) here is optional Ideally you should use WebdriverWait instead of Thread.sleep. But just to show you, I used it.
driver.get('https://www.makemytrip.com/')
time.sleep(3)
driver.find_element(By.XPATH, "//label[#for='departure']").click()
time.sleep(1)
dx = driver.find_element(By.XPATH, "//div[#class='DayPicker-Day DayPicker-Day--today']")
print(dx.text)
dx.click()
Here is the output:
17 is the date and the other value is currency.
17
₹ 9,418
Process finished with exit code 0
This question already has answers here:
How to use an Internet time server to get the time?
(5 answers)
Closed 1 year ago.
I have variable curTime, I want to get the current time of the form 1616572689, there are 2 familiar methods
val curTime: Long = Date().getTime()
or
val curTime = System.currentTimeMillis()
But here's the problem, if I change the time on the phone for example to 2007, then the value of the variable will be incorrect! It will show the year 2007. How do I make sure that the data is taken not from the system, but from the Internet? some site, for example https://timestamp.online/
Please help, couldn't find anything about this problem.
You find an online server with a public API for retrieving the current time, e.g. World Time API. That's just an example, there are other servers, and you should do your own research to find which server best fits your needs and licensing restrictions.
You then perform an HTTP GET request and parse the returned JSON to get the value you seek.
E.g. if you want the current time for US Eastern time zone, you do and HTTP GET from http://worldtimeapi.org/api/timezone/America/New_York, which will respond with something like this:
{
"abbreviation": "EDT",
"client_ip": "73.106.239.191",
"datetime": "2021-03-28T06:37:10.320418-04:00",
"day_of_week": 0,
"day_of_year": 87,
"dst": true,
"dst_from": "2021-03-14T07:00:00+00:00",
"dst_offset": 3600,
"dst_until": "2021-11-07T06:00:00+00:00",
"raw_offset": -18000,
"timezone": "America/New_York",
"unixtime": 1616927830,
"utc_datetime": "2021-03-28T10:37:10.320418+00:00",
"utc_offset": "-04:00",
"week_number": 12
}
The value you're looking for is the unixtime field.
Here is what I have:
I have an index in elasticseach storing thousands of documents. Each document includes a field called 'deviceName'.
Here is what I would like to do with java api:
I want to get all devices stored in my index and their occurence (number of time a device appears in this index).
Here is my java code:
String[] indexVector = new String[1];
indexVector[0] = "myIndex";
String [] values = new String[2];
values[0] = "sum_delta";
values[1] = "count_frames";
String [] totalPercentage = new String[1];
totalPercentage[0] = "devices>per_percentage";
SearchResponse response = (SearchResponse) client.prepareSearch(indexVector)
.setSize(10000)
.addAggregation(AggregationBuilders.terms("devices").field("deviceName")
.size(100)
.subAggregation(AggregationBuilders.sum("sum_delta").field("delta"))
.subAggregation(AggregationBuilders.count("count_frames").field("cnt"))
.subAggregation(PipelineAggregatorBuilders.bucketScript("per_percentage")
.setBucketsPaths(values)
.script(new Script("_value0 / (_value0 + _value1 + 1)"))
)
)
.addAggregation(PipelineAggregatorBuilders.avgBucket("avg_per_all_devices")
.setBucketsPaths(totalPercentage)
)
.execute()
.actionGet();
How I search in Kibana:
Here is my results:
With java API I get 63 devices and with kibana 64 devices. However, the biggest problem for me is the occurence. Indeed, for a device that has a occurence lower than 30, i have the same result with Java api and Kibana. But, when the occurence is larger, kibana returns a occurence greater than the one returned by java API. Example: kibana returns 1010 and in the same time java api returns 880.
I really don't understand why there is so much difference.
Question:
So, please, can you tell me what is wrong in my code and what I have to do ?
Thank you for your attention and your help.
This is possibly because of the setSize parameter. The set size parameter first gets the 10000 documents and then performs aggregation on them while I don't think you are setting such a size in Kibana. Try setting get size to actual doc count and see if ambiguity persists.
I support there be some documents that _value0 + _value1 + 1 equals 0. You can print the response.toString(), I guess there be one shard faild, 880 documents are closed to four-fifths of 1010 documents.
You can also view elasticseach's log, it will print ERROR.
I have the following JSON data:
2015-02-22T04:00:00-05:00 which clearly shows 4am to 5am which is a one hour slot, but in the week agenda view in fullcalendar it is showing as 4am to 6am, as are all 1 hour slots. any ideas why this is happening?
Use the latest version (2.2.6) of the fullcalendar. For some reason this version works fine.
Please refer to this example: Click Here
And here's a sample code that works properly and might help you as well:
var events_array = [
{
title: 'Test1',
start: moment('2015-02-03T05:00:00'),
end : moment('2015-02-03T12'),
tip: 'Test1'},
];
...
$('#calendar').fullCalendar({
events: events_array,
timezone : 'local',
eventRender: function(event, element) {
element.attr('title', event.tip);
}
});
Mikesmithdev answered this one for me, I didn't have an end specified, I thought you could do it with just one string of data.