I have a uri like which has an image

file:///mnt/...............

How to use this uri to get the image but it returns null, please tell me where i am wrong.

Bitmap bitmap = BitmapFactory.decodeFile(uri.getPath());

Simple way to do

This is a simple one line way to do it:

try {
URL url = new URL("http://....");
Bitmap image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch(IOException e) {
System.out.println(e);
}

--

--

How can i change the current date to this format(DD/MM/YYYY) using moment.js?

I have tried below code.

$scope.SearchDate = moment(new Date(), "DD/MM/YYYY");

But it’s return 0037-11-24T18:30:00.000Z. Did't help to format current date.

The Best solution to get date format in moment.js is

You need to call format() function to get the formatted value

$scope.SearchDate = moment(new Date()).format("DD/MM/YYYY")
//or $scope.SearchDate = moment().format("DD/MM/YYYY")

The syntax you have used is used to parse a given string to date object by using the specified format. more ways to do, click here

--

--

Photo by Amza Andrei on Unsplash

Here’s what I’m trying to do. If you’ve ever played Halo or CoD, you’d know that you could change the name of a weapon load-out.

What I’m doing is making it so you can change your load-out name using a text field. Here’s the problem, the load-out name in the load-out menu is a button (to select and view info about that load-out) and I could just write this:

@IBAction func renameClassButton(sender: AnyObject) {
classTopButton.text = "\(classTopTextField)"
}

Except it [classTopButton] is a button which doesn’t allow the ‘.text’ suffix

The solutions is…

You can do:

button.setTitle("my text here", forState: .normal)

Swift 3 and 4:

button.setTitle("my text here", for: .normal)

check similar questions with solutions at SyntaxFix

--

--

SyntaxFix

SyntaxFix

Curated Solutions On Popular Questions — On All Programming Languages, Cloud Computing, Tools etc