parse

An Android Java, JSON, and Twitter REST API example

I don't get to parse too much JSON code with Java because the biggest JSON source I work with is Twitter, and I always use the Twitter4J project to interact with their web services. But a few days ago while working on an Android project, I just wanted to access their "Twitter Trends" REST service, and I used Java and the json.org Java library that comes with Android to parse the Twitter Trends JSON feed like this:

A simple Scala JSON parser example using Lift-JSON

Scala JSON FAQ: How can I parse JSON text or a JSON document with Scala?

As I continue to plug away on my computer voice control application (SARAH), last night I started working with JSON, specifically the Lift-JSON library (part of the Lift Framework), which seems to be the preferred JSON library of the Scala community.

Java SimpleDateFormat example - Convert a Date to a formatted String

Summary: This tutorial demonstrates how to use the Java SimpleDateFormat class to convert a Java Date to a formatted String.

The Java SimpleDateFormat class provides lets you easily convert (a) between a Java String to a Date or (b) perform the opposite conversion, from a Java Date to a String. In this article we'll at several different ways to convert a Java Date object to a nicely formatted String object, and in another article we'll look at a couple of nice ways for converting in the opposite direction.

An AppleScript current time example

AppleScript time FAQ: Can you share an AppleScript example that shows how to work with the current time?

If you ever need an AppleScript current time example, or an AppleScript to parse and format the current time, I hope this following script will be helpful. This AppleScript script gets the current time, formats it, and then speaks the current time back to you in a human-friendly format:

A Ruby JPEG example - Use Ruby to get the date and time from a JPEG file

A few weeks ago when I upgraded my iPhone 3G to iOS 4, I hooked up my iPhone to my old Windows computer, where it was originally sync'd. Downloading my iPhone photos onto my Windows XP computer was a pain, and worse than that, in the process, the iPhone photos were pulled off the phone in some random order, so all the photos are completely out of order when I look at them in the Windows Explorer or the Mac Finder.

Perl and Apache - How to parse Apache access log file records in Perl

Perl Apache log file FAQ: Can you demonstrate how to read an Apache access log file in Perl (How to parse an Apache access log file in Perl)?

I've provided Perl examples before that can be used to read and parse an Apache log file ("How many RSS feed readers do I have?", "A Perl program to read an Apache access log file"), but to make this code a little easier to find, I'm breaking that code out here.

Java SimpleDateFormat - Convert a Java String to a Date

Summary: A Java SimpleDateFormat (date formatting) example, showing how to convert a Java String to a Date.

In an earlier example I showed how to use the Java SimpleDateFormat class to convert from a Date to a String, but you can also use the Java SimpleDateFormat class to convert in the opposite direction, from a given Java String to a Date object.

A Perl configuration file example

Here's some Perl code that I just pulled from a working program that demonstrates how to read a human-readable configuration file in a Perl program:

How do I convert a String to a double with Java?

Question: How do I convert a String to a double with Java?

Answer: Converting a String to a double requires that you first convert the String to a Double object, then convert the Double object to a double data type (Double is an object, while double is a primitive data type).

Here's the source code for an example Java program that performs this conversion:

Java String to number conversions

Java String to number FAQ: How do I convert a String to a number in Java?

You convert a Java String to a number using the methods of the class whose type you want to convert to. For instance, if you want to try to convert a String to an int, you use the parseInt() method of the Java Integer class, like this: 

Syndicate content