Dataset Viewer
Auto-converted to Parquet Duplicate
qid
int64
2
74.7M
question
stringlengths
31
65.1k
date
stringlengths
10
10
metadata
sequence
response_j
stringlengths
4
63.3k
response_k
stringlengths
4
60.5k
26,032,205
Below the code of my view (the javascript code is in the view, just temp just for testing). I'd like assign the ASP.NET MVC model (`@Model`) to the AngularJS scope (`$scope.person`) How can I do this ? Thanks, The view ``` @model MyApp.Person <script> var myApp = angular.module('myApp', []); myApp.controller('pe...
2014/09/25
[ "https://Stackoverflow.com/questions/26032205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/118584/" ]
``` <script> @{ var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); var json = serializer.Serialize(Model); } var myApp = angular.module('myApp', []); myApp.controller('personController', ['$scope', '$http', function ($scope, $http) { $scope.person = @Ht...
I am not sure if this will work with Angular. You can use [**Json.Encode**](http://msdn.microsoft.com/en-us/library/system.web.helpers.json.encode%28v=vs.111%29.aspx) Method converts a data object to a string that is in the JavaScript Object Notation (JSON) format. ``` window.person = @Html.Raw(Json.Encode(Model)); /...
26,032,205
Below the code of my view (the javascript code is in the view, just temp just for testing). I'd like assign the ASP.NET MVC model (`@Model`) to the AngularJS scope (`$scope.person`) How can I do this ? Thanks, The view ``` @model MyApp.Person <script> var myApp = angular.module('myApp', []); myApp.controller('pe...
2014/09/25
[ "https://Stackoverflow.com/questions/26032205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/118584/" ]
I am not sure if this will work with Angular. You can use [**Json.Encode**](http://msdn.microsoft.com/en-us/library/system.web.helpers.json.encode%28v=vs.111%29.aspx) Method converts a data object to a string that is in the JavaScript Object Notation (JSON) format. ``` window.person = @Html.Raw(Json.Encode(Model)); /...
i had the same problem. this will work. in your view: ``` <script> myApp.value('person', @Html.Raw(Model)); </script> ``` and in your (angular) controller: ``` myApp.controller('personController', ['$scope', '$http', 'person' function ($scope, $http, person) { console.log(person); }]); ``` If you "inject...
26,032,205
Below the code of my view (the javascript code is in the view, just temp just for testing). I'd like assign the ASP.NET MVC model (`@Model`) to the AngularJS scope (`$scope.person`) How can I do this ? Thanks, The view ``` @model MyApp.Person <script> var myApp = angular.module('myApp', []); myApp.controller('pe...
2014/09/25
[ "https://Stackoverflow.com/questions/26032205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/118584/" ]
I am not sure if this will work with Angular. You can use [**Json.Encode**](http://msdn.microsoft.com/en-us/library/system.web.helpers.json.encode%28v=vs.111%29.aspx) Method converts a data object to a string that is in the JavaScript Object Notation (JSON) format. ``` window.person = @Html.Raw(Json.Encode(Model)); /...
At first assign value in global java script variable then use it in your separate angular file ```js <script> var obj = '@Html.Raw(Model)'; </script> ``` now in your angular page ```js $scope.person = obj; ```
26,032,205
Below the code of my view (the javascript code is in the view, just temp just for testing). I'd like assign the ASP.NET MVC model (`@Model`) to the AngularJS scope (`$scope.person`) How can I do this ? Thanks, The view ``` @model MyApp.Person <script> var myApp = angular.module('myApp', []); myApp.controller('pe...
2014/09/25
[ "https://Stackoverflow.com/questions/26032205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/118584/" ]
``` <script> @{ var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); var json = serializer.Serialize(Model); } var myApp = angular.module('myApp', []); myApp.controller('personController', ['$scope', '$http', function ($scope, $http) { $scope.person = @Ht...
i had the same problem. this will work. in your view: ``` <script> myApp.value('person', @Html.Raw(Model)); </script> ``` and in your (angular) controller: ``` myApp.controller('personController', ['$scope', '$http', 'person' function ($scope, $http, person) { console.log(person); }]); ``` If you "inject...
26,032,205
Below the code of my view (the javascript code is in the view, just temp just for testing). I'd like assign the ASP.NET MVC model (`@Model`) to the AngularJS scope (`$scope.person`) How can I do this ? Thanks, The view ``` @model MyApp.Person <script> var myApp = angular.module('myApp', []); myApp.controller('pe...
2014/09/25
[ "https://Stackoverflow.com/questions/26032205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/118584/" ]
``` <script> @{ var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); var json = serializer.Serialize(Model); } var myApp = angular.module('myApp', []); myApp.controller('personController', ['$scope', '$http', function ($scope, $http) { $scope.person = @Ht...
At first assign value in global java script variable then use it in your separate angular file ```js <script> var obj = '@Html.Raw(Model)'; </script> ``` now in your angular page ```js $scope.person = obj; ```
8,702,567
Imagine we have a page with a form where users can create their own discussion forum by inserting some data. Inside each forum anyone will be able to post different threads and topics. **Scenario 1:** Use PHP to create a new HTML file every time a user creates his own forum. This would lead to hundreds maybe thousand...
2012/01/02
[ "https://Stackoverflow.com/questions/8702567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/949388/" ]
Scenario 2 is certainly the way to go, keeping pages dynamic allows for editing far less files and means everything will always be the same. With good MySQL tables and relationships the queries to the database shouldn't be that server heavy and your site will still perform a lot better than with hundreds of .html file...
I actually believe Wikipedia uses a database as well. They are just parsing the URL to get the variables instead of using a query string in the URL. And I would have to believe the database would be the way to go. It's still going to be smaller because you'll have a lot less code. If you use HTML, you will be reproduci...
8,702,567
Imagine we have a page with a form where users can create their own discussion forum by inserting some data. Inside each forum anyone will be able to post different threads and topics. **Scenario 1:** Use PHP to create a new HTML file every time a user creates his own forum. This would lead to hundreds maybe thousand...
2012/01/02
[ "https://Stackoverflow.com/questions/8702567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/949388/" ]
Scenario 2 is certainly the way to go, keeping pages dynamic allows for editing far less files and means everything will always be the same. With good MySQL tables and relationships the queries to the database shouldn't be that server heavy and your site will still perform a lot better than with hundreds of .html file...
The best case scenario would be a combination of the two, in this manner: Use one template (scenario 2) to generate these pages on the fly, this way you can have millions of forums, with only one html. With this, you should add a caching feature, which caches (creates a temporary html file) all the forums, so that use...
18,222,853
I have a section on my site I would like to show some alerts or news on. I want to show the first news for x seconds, then move on to the second news for x seconds and not show the first news anymore, and then unto the third and not show the second .. etc. I am just starting with javascript and the code I was making wo...
2013/08/14
[ "https://Stackoverflow.com/questions/18222853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2680861/" ]
Without changing your CSS/HTML, the code below will handle any number of elements, all you have to do is send their IDs as parameter: ``` function showAlternate(ids, interval, currentVisible) { if (currentVisible === undefined) currentVisible = ids.length-1; // last one document.getElementById(ids[currentVisib...
This Pure-JS example will work with any number of divs with your current pattern, so you can have id "news4", "news5", "news6", etc. Also, you can change how frequently the news changes that is shown by changing the INTERVAL variable, in this example the news will change every 1 second. **JSFIDDLE -- <http://jsfiddle...
18,222,853
I have a section on my site I would like to show some alerts or news on. I want to show the first news for x seconds, then move on to the second news for x seconds and not show the first news anymore, and then unto the third and not show the second .. etc. I am just starting with javascript and the code I was making wo...
2013/08/14
[ "https://Stackoverflow.com/questions/18222853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2680861/" ]
First understand what how to use **setInterval()**. You specify 2 paramaters as **function** to call and **delay** which specify how long time to wait between two calls. Then in your example: * setInterval("showIt()", 3000); // will call showIt() each 3000 ms * setInterval("showIt2()", 6000); // will call showIt2() e...
This Pure-JS example will work with any number of divs with your current pattern, so you can have id "news4", "news5", "news6", etc. Also, you can change how frequently the news changes that is shown by changing the INTERVAL variable, in this example the news will change every 1 second. **JSFIDDLE -- <http://jsfiddle...
18,222,853
I have a section on my site I would like to show some alerts or news on. I want to show the first news for x seconds, then move on to the second news for x seconds and not show the first news anymore, and then unto the third and not show the second .. etc. I am just starting with javascript and the code I was making wo...
2013/08/14
[ "https://Stackoverflow.com/questions/18222853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2680861/" ]
I have changed logic of the javascript code like below, ``` var newsList = ["news1","news2","news3"]; var currIndex = newsList.length-1; var timeoutObj; function showNext() { document.getElementById(newsList[currIndex]).style.visibility = "hidden"; if(currIndex >= newsList.length-1) currIndex = 0; ...
This Pure-JS example will work with any number of divs with your current pattern, so you can have id "news4", "news5", "news6", etc. Also, you can change how frequently the news changes that is shown by changing the INTERVAL variable, in this example the news will change every 1 second. **JSFIDDLE -- <http://jsfiddle...
51,579,410
I am using AWS CLI for scheduling the project build. I have successfully executed Test Cases using the AWS CLI using Device Pool(All Android devices) Now I want only one device in my device pool, So I have tried to get the Device ARN. To get ARN for All Devices under Project using: ``` aws devicefarm list-devices -...
2018/07/29
[ "https://Stackoverflow.com/questions/51579410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5944123/" ]
Here is an example that I had in my notes but it's not for the Google pixel. However, its arn can be found using the [list devices](https://docs.aws.amazon.com/devicefarm/latest/APIReference/API_ListDevices.html) API **Single device** `aws devicefarm create-device-pool --project-arn arn:aws:devicefarm:us-west-2:1111...
Provide a more detailed answer based on James. `aws devicefarm create-device-pool --project-arn arn:aws:devicefarm:us-west-2: 111122223333:project:bb8c132f-9c75-4ac2-98fc-59c5e71adbbd --name pixel2_81 --rules '[{"attribute": "ARN","operator":"IN","value":"[\"arn:aws:devicefarm:us-west-2::device:4B2B87829E99484DBCD853D...
772,509
I've used the commands from [this gist](https://gist.github.com/jacobmarshall/77d6b3ba7c6c50de22eb) (duplicated below) to create a Docker Swarm using Consul. ``` docker-machine create \ --driver=digitalocean \ --digitalocean-access-token=$DO_TOKEN \ --digitalocean-size=512mb \ --digitalocean-region=nyc3 \ --...
2016/04/24
[ "https://serverfault.com/questions/772509", "https://serverfault.com", "https://serverfault.com/users/167024/" ]
You have an incorrect setting in your `php.ini` file: The `session.cache_limiter` value is set to `nocache` in the default `php.ini` file and needs to be changed. `session.cache_limiter` should be defined and set, either to `public` which inserts public cache-control headers, or to `''` (blank), which doesn't insert ...
I've found that with Wordpress (some themes) and other PHP applications sometimes it's near to impossible to get the headers set correctly using PHP. My solution is that I just ignore the headers the application sets and override them with what I want in Nginx. I find this much simpler, much faster, and much more relia...
772,509
I've used the commands from [this gist](https://gist.github.com/jacobmarshall/77d6b3ba7c6c50de22eb) (duplicated below) to create a Docker Swarm using Consul. ``` docker-machine create \ --driver=digitalocean \ --digitalocean-access-token=$DO_TOKEN \ --digitalocean-size=512mb \ --digitalocean-region=nyc3 \ --...
2016/04/24
[ "https://serverfault.com/questions/772509", "https://serverfault.com", "https://serverfault.com/users/167024/" ]
You have an incorrect setting in your `php.ini` file: The `session.cache_limiter` value is set to `nocache` in the default `php.ini` file and needs to be changed. `session.cache_limiter` should be defined and set, either to `public` which inserts public cache-control headers, or to `''` (blank), which doesn't insert ...
Most cloud servers using PHP and Nginx these days are going to be using PHP-FPM (or should be)... for cleaner configuration I recommend keeping `session.cache_limiter = nocache` in your `php.ini` and then overwriting HTTP headers using Nginx instead, it's more reliable. For [SlickStack](https://github.com/littlebizzy/...
772,509
I've used the commands from [this gist](https://gist.github.com/jacobmarshall/77d6b3ba7c6c50de22eb) (duplicated below) to create a Docker Swarm using Consul. ``` docker-machine create \ --driver=digitalocean \ --digitalocean-access-token=$DO_TOKEN \ --digitalocean-size=512mb \ --digitalocean-region=nyc3 \ --...
2016/04/24
[ "https://serverfault.com/questions/772509", "https://serverfault.com", "https://serverfault.com/users/167024/" ]
I've found that with Wordpress (some themes) and other PHP applications sometimes it's near to impossible to get the headers set correctly using PHP. My solution is that I just ignore the headers the application sets and override them with what I want in Nginx. I find this much simpler, much faster, and much more relia...
Most cloud servers using PHP and Nginx these days are going to be using PHP-FPM (or should be)... for cleaner configuration I recommend keeping `session.cache_limiter = nocache` in your `php.ini` and then overwriting HTTP headers using Nginx instead, it's more reliable. For [SlickStack](https://github.com/littlebizzy/...
70,398,031
I have a simple component here where I set a state variable called `input` to the value of an array of numbers. Then, within `useEffect` I call a function that randomizes the initial state array, and puts the results in a new state variable called `output`. I need my input array to stay in the same order. However, it ...
2021/12/17
[ "https://Stackoverflow.com/questions/70398031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9040866/" ]
Simple math tells us that this is not possible. The number of unique alphanumeric strings of length 4 (case-insensitive) is 36^4 = 1,679,616 while the number of non-negative unique floating point numbers with at most 3 fractional digits and less than 100 is 10^5 = 100,000. If the string were restricted to hexadecimal ...
Your encoding is somewhat confusing, but here is a simple solution: * use 2 digits for the integral part * use 2 digits for fractional parts `00` to `99` * use a combination of 1 letter and 1 letter or digit for fractional parts `100` to `999`. There are 26\*36 = 936 such combinations, enough to cover the 900 possibil...
36,832,246
I understand the basics of sending a message via the Mailgun API using Python and requests from my site and all works fine. I would like to attach data from an HTML form using request.forms.get(''), but can't figure out the syntax to make it work. The link below is exactly what I need to do, except in Python instead of...
2016/04/25
[ "https://Stackoverflow.com/questions/36832246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4182445/" ]
Here's a scheme for doing request/response over socket.io. You could do this over plain webSocket, but you'd have to build a little more of the infrastructure yourself. This same library can be used in client and server: ``` function initRequestResponseSocket(socket, requestHandler) { var cntr = 0; var openRes...
There are a couple of interesting things in your question and your design, I prefer to ignore the implementation details and look at the high level architecture. You state that you are looking to a client that requests data and a server that responds with some stream of data. Two things to note here: 1. HTTP 1.1 has...
19,347,430
This is my first attempt at using javscript with html/css. I have a button that when clicked shows a question, and three radio buttons. Everything so far so good, but I would like the radio buttons to be aligned with their actual button on the left (not the text). The content div is centered, so it seems like it is jus...
2013/10/13
[ "https://Stackoverflow.com/questions/19347430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2873870/" ]
If `orig` and `pol1` are instances of `Polynomial` then this ``` if (orig.equals(pol1)) ``` would only work if you implement `Polynomial#equals()` as well; which would iterate the two `ArrayList`s and make sure individual `Pair`s are equal (using `Pair#equals()` of course).
Use the [Double.compare(double, double)](http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#compare%28double,%20double%29) method instead of ==. Floating point comparison is "fuzzy" in Java.
19,347,430
This is my first attempt at using javscript with html/css. I have a button that when clicked shows a question, and three radio buttons. Everything so far so good, but I would like the radio buttons to be aligned with their actual button on the left (not the text). The content div is centered, so it seems like it is jus...
2013/10/13
[ "https://Stackoverflow.com/questions/19347430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2873870/" ]
If `orig` and `pol1` are instances of `Polynomial` then this ``` if (orig.equals(pol1)) ``` would only work if you implement `Polynomial#equals()` as well; which would iterate the two `ArrayList`s and make sure individual `Pair`s are equal (using `Pair#equals()` of course).
Ok, thanks to Ravi Thapliyal I found the solution. After adding an custom equals method in my Polynominal class, the problem was fixed. ``` @Override public boolean equals(Object o) { if (!(o instanceof Polynomial)) return false; Polynomial that = (Polynomial) o; return that.terms.equals(terms...
19,347,430
This is my first attempt at using javscript with html/css. I have a button that when clicked shows a question, and three radio buttons. Everything so far so good, but I would like the radio buttons to be aligned with their actual button on the left (not the text). The content div is centered, so it seems like it is jus...
2013/10/13
[ "https://Stackoverflow.com/questions/19347430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2873870/" ]
If `orig` and `pol1` are instances of `Polynomial` then this ``` if (orig.equals(pol1)) ``` would only work if you implement `Polynomial#equals()` as well; which would iterate the two `ArrayList`s and make sure individual `Pair`s are equal (using `Pair#equals()` of course).
You would need to implement a Polynomail.equals() method something like the following: ``` public boolean equals(Object o) { if (!(o instanceof Polynomial)) return false; Polynomial other = (Polynomial) o; if (this.terms==null && other.terms==null) return true; // A suitable equals() method already exists f...
19,347,430
This is my first attempt at using javscript with html/css. I have a button that when clicked shows a question, and three radio buttons. Everything so far so good, but I would like the radio buttons to be aligned with their actual button on the left (not the text). The content div is centered, so it seems like it is jus...
2013/10/13
[ "https://Stackoverflow.com/questions/19347430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2873870/" ]
If `orig` and `pol1` are instances of `Polynomial` then this ``` if (orig.equals(pol1)) ``` would only work if you implement `Polynomial#equals()` as well; which would iterate the two `ArrayList`s and make sure individual `Pair`s are equal (using `Pair#equals()` of course).
Two issues come to mind: the first is that the default `hashCode()` method will seldom return the same value for any two distinct object instances, regardless of their contents. This is a good thing if the `equals()` method will never report two distinct object instances as equal, but is a bad thing if it will. *Every*...
19,347,430
This is my first attempt at using javscript with html/css. I have a button that when clicked shows a question, and three radio buttons. Everything so far so good, but I would like the radio buttons to be aligned with their actual button on the left (not the text). The content div is centered, so it seems like it is jus...
2013/10/13
[ "https://Stackoverflow.com/questions/19347430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2873870/" ]
Ok, thanks to Ravi Thapliyal I found the solution. After adding an custom equals method in my Polynominal class, the problem was fixed. ``` @Override public boolean equals(Object o) { if (!(o instanceof Polynomial)) return false; Polynomial that = (Polynomial) o; return that.terms.equals(terms...
Use the [Double.compare(double, double)](http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#compare%28double,%20double%29) method instead of ==. Floating point comparison is "fuzzy" in Java.
19,347,430
This is my first attempt at using javscript with html/css. I have a button that when clicked shows a question, and three radio buttons. Everything so far so good, but I would like the radio buttons to be aligned with their actual button on the left (not the text). The content div is centered, so it seems like it is jus...
2013/10/13
[ "https://Stackoverflow.com/questions/19347430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2873870/" ]
Ok, thanks to Ravi Thapliyal I found the solution. After adding an custom equals method in my Polynominal class, the problem was fixed. ``` @Override public boolean equals(Object o) { if (!(o instanceof Polynomial)) return false; Polynomial that = (Polynomial) o; return that.terms.equals(terms...
You would need to implement a Polynomail.equals() method something like the following: ``` public boolean equals(Object o) { if (!(o instanceof Polynomial)) return false; Polynomial other = (Polynomial) o; if (this.terms==null && other.terms==null) return true; // A suitable equals() method already exists f...
19,347,430
This is my first attempt at using javscript with html/css. I have a button that when clicked shows a question, and three radio buttons. Everything so far so good, but I would like the radio buttons to be aligned with their actual button on the left (not the text). The content div is centered, so it seems like it is jus...
2013/10/13
[ "https://Stackoverflow.com/questions/19347430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2873870/" ]
Ok, thanks to Ravi Thapliyal I found the solution. After adding an custom equals method in my Polynominal class, the problem was fixed. ``` @Override public boolean equals(Object o) { if (!(o instanceof Polynomial)) return false; Polynomial that = (Polynomial) o; return that.terms.equals(terms...
Two issues come to mind: the first is that the default `hashCode()` method will seldom return the same value for any two distinct object instances, regardless of their contents. This is a good thing if the `equals()` method will never report two distinct object instances as equal, but is a bad thing if it will. *Every*...
16,739,212
I need to fill a html webview with variables that I have stored in objective C. I believe that I need to use: ``` [self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"John", firstName]; ``` but not sure what to put there and what my javascript needs to be to implement the passed variabl...
2013/05/24
[ "https://Stackoverflow.com/questions/16739212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1455182/" ]
Basically you need a javascript method to add the data to the HTML string. Once you have the function, passing data to it is fairly straight forward, ``` NSString *script = [NSString stringWithFormat:@"methodName([%@])", data] [self.webView stringByEvaluatingJavaScriptFromString:script]; ``` And writing Javascript ...
Do you have access to the raw HTML string in your code? If so, can you do something like that? ``` UIWebView *webview = [[UIWebView alloc] initWithFrame:self.view.bounds]; [self.view addSubview:webview]; NSString *htmlString = [NSString stringWithFormat:@"<html>\ <ul><li><span>First Name:</span> %@</li>\ <li><span>Las...
16,739,212
I need to fill a html webview with variables that I have stored in objective C. I believe that I need to use: ``` [self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"John", firstName]; ``` but not sure what to put there and what my javascript needs to be to implement the passed variabl...
2013/05/24
[ "https://Stackoverflow.com/questions/16739212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1455182/" ]
I ended up using a different js approach and used, hopefully this is helpful to someone. obj c: ``` NSString *str = @"John"; NSString *script = [NSString stringWithFormat:@"document.getElementById('name').innerHTML = '%@';", str]; [self.webView stringByEvaluatingJavaScriptFromString:script]; ``` js: ``` <li><span...
Basically you need a javascript method to add the data to the HTML string. Once you have the function, passing data to it is fairly straight forward, ``` NSString *script = [NSString stringWithFormat:@"methodName([%@])", data] [self.webView stringByEvaluatingJavaScriptFromString:script]; ``` And writing Javascript ...
16,739,212
I need to fill a html webview with variables that I have stored in objective C. I believe that I need to use: ``` [self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"John", firstName]; ``` but not sure what to put there and what my javascript needs to be to implement the passed variabl...
2013/05/24
[ "https://Stackoverflow.com/questions/16739212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1455182/" ]
I ended up using a different js approach and used, hopefully this is helpful to someone. obj c: ``` NSString *str = @"John"; NSString *script = [NSString stringWithFormat:@"document.getElementById('name').innerHTML = '%@';", str]; [self.webView stringByEvaluatingJavaScriptFromString:script]; ``` js: ``` <li><span...
Do you have access to the raw HTML string in your code? If so, can you do something like that? ``` UIWebView *webview = [[UIWebView alloc] initWithFrame:self.view.bounds]; [self.view addSubview:webview]; NSString *htmlString = [NSString stringWithFormat:@"<html>\ <ul><li><span>First Name:</span> %@</li>\ <li><span>Las...
6,394,223
I think I've read just about everything out there on the topic of logging out of Facebook inside of a Desktop application. Nothing so far works. Specifically, I would like to log the user out so that they can switch identities, e.g. People sharing a computer at home could then use the software with their own Facebook...
2011/06/18
[ "https://Stackoverflow.com/questions/6394223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/804186/" ]
Well, I've turned up nothing that works, so I've resorted to a nasty hack. The FacebookOAuthClient.GetLogoutUrl() method URL does not log me out, however, it does return an "m.facebook.com" URL, e.g.: <http://m.facebook.com/logout.php?next=http://www.facebook.com/dialog/oauth/?response_type=token&display=popup&scope...
See this [blog post](http://blog.prabir.me/post/Facebook-CSharp-SDK-Logout.aspx) Get the logout url using FacebookOAuthClient() & send a http request to the url..
6,394,223
I think I've read just about everything out there on the topic of logging out of Facebook inside of a Desktop application. Nothing so far works. Specifically, I would like to log the user out so that they can switch identities, e.g. People sharing a computer at home could then use the software with their own Facebook...
2011/06/18
[ "https://Stackoverflow.com/questions/6394223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/804186/" ]
This question has been answered [here](https://stackoverflow.com/questions/6023908/facebook-logout-c-sdk), the suggestion is to use the url below to logout since facebook is apparently skipping the "next" parameter ``` https://www.facebook.com/logout.php?next=[redirect_uri]&access_token=[access_token] ```
See this [blog post](http://blog.prabir.me/post/Facebook-CSharp-SDK-Logout.aspx) Get the logout url using FacebookOAuthClient() & send a http request to the url..
6,394,223
I think I've read just about everything out there on the topic of logging out of Facebook inside of a Desktop application. Nothing so far works. Specifically, I would like to log the user out so that they can switch identities, e.g. People sharing a computer at home could then use the software with their own Facebook...
2011/06/18
[ "https://Stackoverflow.com/questions/6394223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/804186/" ]
I'm guessing you want to log the user out so you can log another account in. In which case I would suggest this approach using the WebAuthenticationBroker: After quite a while experimenting and having no luck with any of the examples above I have worked out that submitting a logout request with the redirect url to you...
See this [blog post](http://blog.prabir.me/post/Facebook-CSharp-SDK-Logout.aspx) Get the logout url using FacebookOAuthClient() & send a http request to the url..
6,394,223
I think I've read just about everything out there on the topic of logging out of Facebook inside of a Desktop application. Nothing so far works. Specifically, I would like to log the user out so that they can switch identities, e.g. People sharing a computer at home could then use the software with their own Facebook...
2011/06/18
[ "https://Stackoverflow.com/questions/6394223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/804186/" ]
This question has been answered [here](https://stackoverflow.com/questions/6023908/facebook-logout-c-sdk), the suggestion is to use the url below to logout since facebook is apparently skipping the "next" parameter ``` https://www.facebook.com/logout.php?next=[redirect_uri]&access_token=[access_token] ```
Well, I've turned up nothing that works, so I've resorted to a nasty hack. The FacebookOAuthClient.GetLogoutUrl() method URL does not log me out, however, it does return an "m.facebook.com" URL, e.g.: <http://m.facebook.com/logout.php?next=http://www.facebook.com/dialog/oauth/?response_type=token&display=popup&scope...
6,394,223
I think I've read just about everything out there on the topic of logging out of Facebook inside of a Desktop application. Nothing so far works. Specifically, I would like to log the user out so that they can switch identities, e.g. People sharing a computer at home could then use the software with their own Facebook...
2011/06/18
[ "https://Stackoverflow.com/questions/6394223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/804186/" ]
Well, I've turned up nothing that works, so I've resorted to a nasty hack. The FacebookOAuthClient.GetLogoutUrl() method URL does not log me out, however, it does return an "m.facebook.com" URL, e.g.: <http://m.facebook.com/logout.php?next=http://www.facebook.com/dialog/oauth/?response_type=token&display=popup&scope...
had the same problem with missing log out button and found via google this hint the other day: open <https://developers.facebook.com/?ref=pf> (called "facebook developers site") and there you can find the usual log in/out button again. dont ask me how it works and why it works, I only followed the instructions I foun...
6,394,223
I think I've read just about everything out there on the topic of logging out of Facebook inside of a Desktop application. Nothing so far works. Specifically, I would like to log the user out so that they can switch identities, e.g. People sharing a computer at home could then use the software with their own Facebook...
2011/06/18
[ "https://Stackoverflow.com/questions/6394223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/804186/" ]
This question has been answered [here](https://stackoverflow.com/questions/6023908/facebook-logout-c-sdk), the suggestion is to use the url below to logout since facebook is apparently skipping the "next" parameter ``` https://www.facebook.com/logout.php?next=[redirect_uri]&access_token=[access_token] ```
had the same problem with missing log out button and found via google this hint the other day: open <https://developers.facebook.com/?ref=pf> (called "facebook developers site") and there you can find the usual log in/out button again. dont ask me how it works and why it works, I only followed the instructions I foun...
6,394,223
I think I've read just about everything out there on the topic of logging out of Facebook inside of a Desktop application. Nothing so far works. Specifically, I would like to log the user out so that they can switch identities, e.g. People sharing a computer at home could then use the software with their own Facebook...
2011/06/18
[ "https://Stackoverflow.com/questions/6394223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/804186/" ]
This question has been answered [here](https://stackoverflow.com/questions/6023908/facebook-logout-c-sdk), the suggestion is to use the url below to logout since facebook is apparently skipping the "next" parameter ``` https://www.facebook.com/logout.php?next=[redirect_uri]&access_token=[access_token] ```
I'm guessing you want to log the user out so you can log another account in. In which case I would suggest this approach using the WebAuthenticationBroker: After quite a while experimenting and having no luck with any of the examples above I have worked out that submitting a logout request with the redirect url to you...
6,394,223
I think I've read just about everything out there on the topic of logging out of Facebook inside of a Desktop application. Nothing so far works. Specifically, I would like to log the user out so that they can switch identities, e.g. People sharing a computer at home could then use the software with their own Facebook...
2011/06/18
[ "https://Stackoverflow.com/questions/6394223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/804186/" ]
I'm guessing you want to log the user out so you can log another account in. In which case I would suggest this approach using the WebAuthenticationBroker: After quite a while experimenting and having no luck with any of the examples above I have worked out that submitting a logout request with the redirect url to you...
had the same problem with missing log out button and found via google this hint the other day: open <https://developers.facebook.com/?ref=pf> (called "facebook developers site") and there you can find the usual log in/out button again. dont ask me how it works and why it works, I only followed the instructions I foun...
71,878,186
Here is the error message > > JavaScript compilation error: Uncaught SyntaxError: Unexpected token '>' in HP\_SEARCHCBHMESSAGES at ' if (Fac123 <> "") ' position 1.. > > > Some reason SF doesn't like if condition (Fac123 <> "" ), have tried if (Fac123 <> '' ) but same error Please help! ``` CALL PROC1('param1' ...
2022/04/14
[ "https://Stackoverflow.com/questions/71878186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1810575/" ]
Inside a JavaScript procedure the only valid language to use is Javascript. Therefore you have to use a javascript "not equals" which is `!==` ``` CREATE OR REPLACE PROCEDURE PROC1("param1" nvarchar(100) ) returns varchar language javascript AS $$ var Fac123 = param1 if (Fac123 !== "" ) { sql12 = " AND " } ret...
Need to fix 'if' statement and put semi-colon after var declaration, please refer below - Error Code - ``` CREATE OR REPLACE PROCEDURE PROC1("param1" nvarchar(100) ) returns varchar language javascript AS $$ var Fac123 = param1 if (Fac123 <> "" ) { sql12 = " AND " } return sql12 ; $$ ; +----------------...
71,878,186
Here is the error message > > JavaScript compilation error: Uncaught SyntaxError: Unexpected token '>' in HP\_SEARCHCBHMESSAGES at ' if (Fac123 <> "") ' position 1.. > > > Some reason SF doesn't like if condition (Fac123 <> "" ), have tried if (Fac123 <> '' ) but same error Please help! ``` CALL PROC1('param1' ...
2022/04/14
[ "https://Stackoverflow.com/questions/71878186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1810575/" ]
The provided code suggests a trial to build a code generator, a pattern called kitchen sink(i.e. if a parameter is provided it should be included otherwise removed from WHERE condion). Alternative approach is to simply use NULL safe comparison. If the missing value is passed as empty string then: ``` SELECT * FROM .....
Need to fix 'if' statement and put semi-colon after var declaration, please refer below - Error Code - ``` CREATE OR REPLACE PROCEDURE PROC1("param1" nvarchar(100) ) returns varchar language javascript AS $$ var Fac123 = param1 if (Fac123 <> "" ) { sql12 = " AND " } return sql12 ; $$ ; +----------------...
71,878,186
Here is the error message > > JavaScript compilation error: Uncaught SyntaxError: Unexpected token '>' in HP\_SEARCHCBHMESSAGES at ' if (Fac123 <> "") ' position 1.. > > > Some reason SF doesn't like if condition (Fac123 <> "" ), have tried if (Fac123 <> '' ) but same error Please help! ``` CALL PROC1('param1' ...
2022/04/14
[ "https://Stackoverflow.com/questions/71878186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1810575/" ]
Inside a JavaScript procedure the only valid language to use is Javascript. Therefore you have to use a javascript "not equals" which is `!==` ``` CREATE OR REPLACE PROCEDURE PROC1("param1" nvarchar(100) ) returns varchar language javascript AS $$ var Fac123 = param1 if (Fac123 !== "" ) { sql12 = " AND " } ret...
The provided code suggests a trial to build a code generator, a pattern called kitchen sink(i.e. if a parameter is provided it should be included otherwise removed from WHERE condion). Alternative approach is to simply use NULL safe comparison. If the missing value is passed as empty string then: ``` SELECT * FROM .....
21,975,881
I'm wondering how to select an element that does not have a specific class using JavaScript, not jQuery. For example, I have this list: ``` <ul id="tasks"> <li class="completed selected">One Task</li> <li>Two Task</li> </ul> ``` and I select the completed task by: ``` var completeTask = document.querySelector(...
2014/02/23
[ "https://Stackoverflow.com/questions/21975881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2741060/" ]
This selects the second `LI` element. ``` document.querySelector("li:not([class])") ``` or ``` document.querySelector("li:not(.completed):not(.selected)") ``` **Example:** ```js // select li which doesn't have a 'class' attribute... console.log(document.querySelector("li:not([class])")) // select li which doe...
``` document.querySelectorAll('[wf-body=details] input:not(.switch):not(.btn)').forEach(function(e){ // do whatever you want. with 'e' as element :P }); ```
21,975,881
I'm wondering how to select an element that does not have a specific class using JavaScript, not jQuery. For example, I have this list: ``` <ul id="tasks"> <li class="completed selected">One Task</li> <li>Two Task</li> </ul> ``` and I select the completed task by: ``` var completeTask = document.querySelector(...
2014/02/23
[ "https://Stackoverflow.com/questions/21975881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2741060/" ]
This selects the second `LI` element. ``` document.querySelector("li:not([class])") ``` or ``` document.querySelector("li:not(.completed):not(.selected)") ``` **Example:** ```js // select li which doesn't have a 'class' attribute... console.log(document.querySelector("li:not([class])")) // select li which doe...
The `:not(*selector*)` selector also accepts commas (so does `querySelectorAll()`) <https://developer.mozilla.org/en-US/docs/Web/CSS/:not#syntax>: ```js let plainElements = document.querySelectorAll( ':not( .completed, .in-progress ) '); plainElements.forEach( ( item ) => { item.style.color = 'red'; } ); ``` ```css l...
21,975,881
I'm wondering how to select an element that does not have a specific class using JavaScript, not jQuery. For example, I have this list: ``` <ul id="tasks"> <li class="completed selected">One Task</li> <li>Two Task</li> </ul> ``` and I select the completed task by: ``` var completeTask = document.querySelector(...
2014/02/23
[ "https://Stackoverflow.com/questions/21975881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2741060/" ]
You can try the `:not()` selector ``` var completeTask = document.querySelector("li:not(.completed):not(.selected)"); ``` <http://jsfiddle.net/UM3j5/>
``` document.querySelectorAll('[wf-body=details] input:not(.switch):not(.btn)').forEach(function(e){ // do whatever you want. with 'e' as element :P }); ```
21,975,881
I'm wondering how to select an element that does not have a specific class using JavaScript, not jQuery. For example, I have this list: ``` <ul id="tasks"> <li class="completed selected">One Task</li> <li>Two Task</li> </ul> ``` and I select the completed task by: ``` var completeTask = document.querySelector(...
2014/02/23
[ "https://Stackoverflow.com/questions/21975881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2741060/" ]
This selects the second `LI` element. ``` document.querySelector("li:not([class])") ``` or ``` document.querySelector("li:not(.completed):not(.selected)") ``` **Example:** ```js // select li which doesn't have a 'class' attribute... console.log(document.querySelector("li:not([class])")) // select li which doe...
To select the `<li>` that has not `completed` nor `selected` class: ``` document.querySelector("li:not(.completed):not(.selected)"); ``` **Fiddle** <http://jsfiddle.net/Z8djF/>
21,975,881
I'm wondering how to select an element that does not have a specific class using JavaScript, not jQuery. For example, I have this list: ``` <ul id="tasks"> <li class="completed selected">One Task</li> <li>Two Task</li> </ul> ``` and I select the completed task by: ``` var completeTask = document.querySelector(...
2014/02/23
[ "https://Stackoverflow.com/questions/21975881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2741060/" ]
This selects the second `LI` element. ``` document.querySelector("li:not([class])") ``` or ``` document.querySelector("li:not(.completed):not(.selected)") ``` **Example:** ```js // select li which doesn't have a 'class' attribute... console.log(document.querySelector("li:not([class])")) // select li which doe...
Try getting an array of the parent's children instead: ``` var completeTask = document.querySelector("#tasks").childNodes; ``` Then loop/search them as necessary.
21,975,881
I'm wondering how to select an element that does not have a specific class using JavaScript, not jQuery. For example, I have this list: ``` <ul id="tasks"> <li class="completed selected">One Task</li> <li>Two Task</li> </ul> ``` and I select the completed task by: ``` var completeTask = document.querySelector(...
2014/02/23
[ "https://Stackoverflow.com/questions/21975881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2741060/" ]
To select the `<li>` that has not `completed` nor `selected` class: ``` document.querySelector("li:not(.completed):not(.selected)"); ``` **Fiddle** <http://jsfiddle.net/Z8djF/>
You can try the `:not()` selector ``` var completeTask = document.querySelector("li:not(.completed):not(.selected)"); ``` <http://jsfiddle.net/UM3j5/>
21,975,881
I'm wondering how to select an element that does not have a specific class using JavaScript, not jQuery. For example, I have this list: ``` <ul id="tasks"> <li class="completed selected">One Task</li> <li>Two Task</li> </ul> ``` and I select the completed task by: ``` var completeTask = document.querySelector(...
2014/02/23
[ "https://Stackoverflow.com/questions/21975881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2741060/" ]
The `:not(*selector*)` selector also accepts commas (so does `querySelectorAll()`) <https://developer.mozilla.org/en-US/docs/Web/CSS/:not#syntax>: ```js let plainElements = document.querySelectorAll( ':not( .completed, .in-progress ) '); plainElements.forEach( ( item ) => { item.style.color = 'red'; } ); ``` ```css l...
Try getting an array of the parent's children instead: ``` var completeTask = document.querySelector("#tasks").childNodes; ``` Then loop/search them as necessary.
21,975,881
I'm wondering how to select an element that does not have a specific class using JavaScript, not jQuery. For example, I have this list: ``` <ul id="tasks"> <li class="completed selected">One Task</li> <li>Two Task</li> </ul> ``` and I select the completed task by: ``` var completeTask = document.querySelector(...
2014/02/23
[ "https://Stackoverflow.com/questions/21975881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2741060/" ]
To select the `<li>` that has not `completed` nor `selected` class: ``` document.querySelector("li:not(.completed):not(.selected)"); ``` **Fiddle** <http://jsfiddle.net/Z8djF/>
``` document.querySelectorAll('[wf-body=details] input:not(.switch):not(.btn)').forEach(function(e){ // do whatever you want. with 'e' as element :P }); ```
21,975,881
I'm wondering how to select an element that does not have a specific class using JavaScript, not jQuery. For example, I have this list: ``` <ul id="tasks"> <li class="completed selected">One Task</li> <li>Two Task</li> </ul> ``` and I select the completed task by: ``` var completeTask = document.querySelector(...
2014/02/23
[ "https://Stackoverflow.com/questions/21975881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2741060/" ]
This selects the second `LI` element. ``` document.querySelector("li:not([class])") ``` or ``` document.querySelector("li:not(.completed):not(.selected)") ``` **Example:** ```js // select li which doesn't have a 'class' attribute... console.log(document.querySelector("li:not([class])")) // select li which doe...
You can try the `:not()` selector ``` var completeTask = document.querySelector("li:not(.completed):not(.selected)"); ``` <http://jsfiddle.net/UM3j5/>
21,975,881
I'm wondering how to select an element that does not have a specific class using JavaScript, not jQuery. For example, I have this list: ``` <ul id="tasks"> <li class="completed selected">One Task</li> <li>Two Task</li> </ul> ``` and I select the completed task by: ``` var completeTask = document.querySelector(...
2014/02/23
[ "https://Stackoverflow.com/questions/21975881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2741060/" ]
``` document.querySelectorAll('[wf-body=details] input:not(.switch):not(.btn)').forEach(function(e){ // do whatever you want. with 'e' as element :P }); ```
Try getting an array of the parent's children instead: ``` var completeTask = document.querySelector("#tasks").childNodes; ``` Then loop/search them as necessary.
34,529,557
I want to create a simple `Angular2` Application using `TypeScript`. Seems, pretty simple, but I am not able to achieve what I wanted to. I want to show a property value in the template. And I want to update the same after 1 second using setTimeout. Plunkr Code is here : [Code on Plunkr](http://plnkr.co/edit/RhYhVS84...
2015/12/30
[ "https://Stackoverflow.com/questions/34529557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3467552/" ]
This is not valid TypeScript code. You can not have method invocations in the body of a class. ```js // INVALID CODE export class AppComponent { public n: number = 1; setTimeout(function() { n = n + 10; }, 1000); } ``` Instead move the `setTimeout` call to the `constructor` of the class. Additionally, use ...
You should put your processing into the class constructor or an `OnInit` hook method.
5,892,956
I am trying to minimize my code by putting it into an array but nothing happens. I can't figure out what I am doing wrong. Here's the code ``` <html> <head> <title>test</title> <!-- JavaScript --> <script src="js/jquery-1.5.2.js" type="text/javascript"></script> <script type="text/javascript">...
2011/05/05
[ "https://Stackoverflow.com/questions/5892956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/729678/" ]
Your initializers shouldn't look like this: ``` var phpfile = new Array(); phpfile["testselect"] = "zoomchange.php"; var elementID = new Array(); elementID["testselect"] = "#testdiv"; ``` A JavaScript Array is indexed by numbers, not strings. You want simple object literals: ``` var phpfile = { testselect: 'zoom...
You should do `new Object()` instead of `new Array()`. **Edit**: There are other mistakes, your js code should be this: ``` <script type="text/javascript"> var phpfile = {}; phpfile["testselect"] = "zoomchange.php"; var elementID = {}; elementID["testselect"] = "#testdiv"; $(d...
5,892,956
I am trying to minimize my code by putting it into an array but nothing happens. I can't figure out what I am doing wrong. Here's the code ``` <html> <head> <title>test</title> <!-- JavaScript --> <script src="js/jquery-1.5.2.js" type="text/javascript"></script> <script type="text/javascript">...
2011/05/05
[ "https://Stackoverflow.com/questions/5892956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/729678/" ]
Your initializers shouldn't look like this: ``` var phpfile = new Array(); phpfile["testselect"] = "zoomchange.php"; var elementID = new Array(); elementID["testselect"] = "#testdiv"; ``` A JavaScript Array is indexed by numbers, not strings. You want simple object literals: ``` var phpfile = { testselect: 'zoom...
This ``` function(data) { $(elementID[$(this).id()]).html(data); } ``` instead of this ``` function(data) { $(elementID[$(this).id()]).html(data) } ``` Is this the error ?
9,243,578
I am having the following problem in Java (I see some people are having a similar problem in JavaScript but I'm using Java) ``` System.out.println(new Date().getYear()); System.out.println(new GregorianCalendar().getTime().getYear()); System.out.println(this.sale.getSaleDate().getYear()); System.out.println(this.sale....
2012/02/11
[ "https://Stackoverflow.com/questions/9243578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1139027/" ]
Don't use `Date`, use `Calendar`: ``` // Beware: months are zero-based and no out of range errors are reported Calendar date = new GregorianCalendar(2012, 9, 5); int year = date.get(Calendar.YEAR); // 2012 int month = date.get(Calendar.MONTH); // 9 - October!!! int day = date.get(Calendar.DAY_OF_MONTH); // 5 ``` ...
``` try{ int year = Integer.parseInt(new Date().toString().split("-")[0]); } catch(NumberFormatException e){ } ``` Much of Date is deprecated.
9,243,578
I am having the following problem in Java (I see some people are having a similar problem in JavaScript but I'm using Java) ``` System.out.println(new Date().getYear()); System.out.println(new GregorianCalendar().getTime().getYear()); System.out.println(this.sale.getSaleDate().getYear()); System.out.println(this.sale....
2012/02/11
[ "https://Stackoverflow.com/questions/9243578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1139027/" ]
tl;dr ===== ``` LocalDate.now() // Capture the date-only value current in the JVM’s current default time zone. .getYear() // Extract the year number from that date. ``` > > 2018 > > > java.time ========= Both the `java.util.Date` and `java.util.Calendar` classes are legacy, now supplanted by t...
This behavior is documented in the [java.util.Date](http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Date.html#getYear%28%29) -class documentation: > > Returns a value that is the result of subtracting 1900 from the year > that contains or begins with the instant in time represented by this > Date object, as ...
9,243,578
I am having the following problem in Java (I see some people are having a similar problem in JavaScript but I'm using Java) ``` System.out.println(new Date().getYear()); System.out.println(new GregorianCalendar().getTime().getYear()); System.out.println(this.sale.getSaleDate().getYear()); System.out.println(this.sale....
2012/02/11
[ "https://Stackoverflow.com/questions/9243578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1139027/" ]
Use date format ``` SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = format.parse(datetime); SimpleDateFormat df = new SimpleDateFormat("yyyy"); year = df.format(date); ```
Yup, this is in fact what's happening. See also the [Javadoc](http://docs.oracle.com/javase/6/docs/api/java/util/Date.html#getYear%28%29): > > > ``` > Returns: > the year represented by this date, minus 1900. > > ``` > > The getYear method is deprecated for this reason. So, don't use it. Note also that getMo...
9,243,578
I am having the following problem in Java (I see some people are having a similar problem in JavaScript but I'm using Java) ``` System.out.println(new Date().getYear()); System.out.println(new GregorianCalendar().getTime().getYear()); System.out.println(this.sale.getSaleDate().getYear()); System.out.println(this.sale....
2012/02/11
[ "https://Stackoverflow.com/questions/9243578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1139027/" ]
According to javadocs: ``` @Deprecated public int getYear() ``` **Deprecated**. As of JDK version 1.1, replaced by `Calendar.get(Calendar.YEAR) - 1900`. Returns a value that is the result of subtracting 1900 from the year that contains or begins with the instant in time represented by this Date object, as interpret...
Java 8 LocalDate class is another option to get the year from a java.util.Date, ``` int year = LocalDate.parse(new SimpleDateFormat("yyyy-MM-dd").format(date)).getYear(); ``` Another option is, ``` int year = Integer.parseInt(new SimpleDateFormat("yyyy").format(date)); ```
9,243,578
I am having the following problem in Java (I see some people are having a similar problem in JavaScript but I'm using Java) ``` System.out.println(new Date().getYear()); System.out.println(new GregorianCalendar().getTime().getYear()); System.out.println(this.sale.getSaleDate().getYear()); System.out.println(this.sale....
2012/02/11
[ "https://Stackoverflow.com/questions/9243578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1139027/" ]
Don't use `Date`, use `Calendar`: ``` // Beware: months are zero-based and no out of range errors are reported Calendar date = new GregorianCalendar(2012, 9, 5); int year = date.get(Calendar.YEAR); // 2012 int month = date.get(Calendar.MONTH); // 9 - October!!! int day = date.get(Calendar.DAY_OF_MONTH); // 5 ``` ...
Yup, this is in fact what's happening. See also the [Javadoc](http://docs.oracle.com/javase/6/docs/api/java/util/Date.html#getYear%28%29): > > > ``` > Returns: > the year represented by this date, minus 1900. > > ``` > > The getYear method is deprecated for this reason. So, don't use it. Note also that getMo...
9,243,578
I am having the following problem in Java (I see some people are having a similar problem in JavaScript but I'm using Java) ``` System.out.println(new Date().getYear()); System.out.println(new GregorianCalendar().getTime().getYear()); System.out.println(this.sale.getSaleDate().getYear()); System.out.println(this.sale....
2012/02/11
[ "https://Stackoverflow.com/questions/9243578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1139027/" ]
tl;dr ===== ``` LocalDate.now() // Capture the date-only value current in the JVM’s current default time zone. .getYear() // Extract the year number from that date. ``` > > 2018 > > > java.time ========= Both the `java.util.Date` and `java.util.Calendar` classes are legacy, now supplanted by t...
``` try{ int year = Integer.parseInt(new Date().toString().split("-")[0]); } catch(NumberFormatException e){ } ``` Much of Date is deprecated.
9,243,578
I am having the following problem in Java (I see some people are having a similar problem in JavaScript but I'm using Java) ``` System.out.println(new Date().getYear()); System.out.println(new GregorianCalendar().getTime().getYear()); System.out.println(this.sale.getSaleDate().getYear()); System.out.println(this.sale....
2012/02/11
[ "https://Stackoverflow.com/questions/9243578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1139027/" ]
The java documentation suggests to make use of Calendar class instead of this deprecated way Here is the sample code to set up the calendar object ``` Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); ``` Here is the sample code to get the year, month, etc. ``` System.out.println(calendar.ge...
There are may ways of getting day, month and year in java. You may use any- ``` Date date1 = new Date(); String mmddyyyy1 = new SimpleDateFormat("MM-dd-yyyy").format(date1); System.out.println("Formatted Date 1: " + mmddyyyy1); Date date2 = new Date(); Calendar calendar1 = new GregorianCalendar()...
9,243,578
I am having the following problem in Java (I see some people are having a similar problem in JavaScript but I'm using Java) ``` System.out.println(new Date().getYear()); System.out.println(new GregorianCalendar().getTime().getYear()); System.out.println(this.sale.getSaleDate().getYear()); System.out.println(this.sale....
2012/02/11
[ "https://Stackoverflow.com/questions/9243578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1139027/" ]
Use date format ``` SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = format.parse(datetime); SimpleDateFormat df = new SimpleDateFormat("yyyy"); year = df.format(date); ```
There are may ways of getting day, month and year in java. You may use any- ``` Date date1 = new Date(); String mmddyyyy1 = new SimpleDateFormat("MM-dd-yyyy").format(date1); System.out.println("Formatted Date 1: " + mmddyyyy1); Date date2 = new Date(); Calendar calendar1 = new GregorianCalendar()...
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
3