Check If Date Is Within Supplied Range Using Joda Time

Supposed you need to know if certain date is within a given range of dates, here is how you do it using JodaTime:

//initialize a start & end time variable
DateTime start = new DateTime(1434931200000);
DateTime end = new DateTime(1435276800000);

//supply the start and end to an interval object
Interval interval = new Interval(start, end);

//this is the time that we need to check
DateTime timeToTest = new DateTime(1435046200000);

//now, check if the time is indeed within out specified start and end range
    System.out.println("Time is within range.");
} else {
    System.out.println("Time is outside the defined range.");    


Fixing SmartLocation Doesn’t Work On Devices Without Google Play Services

Hi, me again in this quick tips. Stumbled upon a problem where SmartLocation library doesn’t work on devices without google play services. Apparently, you need to change the location provider and LocationParams config. Below is gist I created:

Continue reading “Fixing SmartLocation Doesn’t Work On Devices Without Google Play Services”


Another Resource For Exercise

Being work in a boring, flat, and little challenge job will make your brain freeze. But, This week, google reader has give me some stuff that will keep me UP and running with something to play with. Here is several thing I would like to play with:

  • Dreamhost API!: I’m not gonna chase the $10000 prizes, I don’t have the time to do it. But, I think it would be cool to play with this API.
  • AppEngine JAVA Support: This is a BIG distraction to my python learning progress.
  • Language detection using Google AJAX API: Another API to play with. Btw, for wordpress developer and general web developer, you should subscribe to his feed. He has scripts and ideas to build something, in the better ways!

Creating Random Password in JAVA

Sometime, we need to create a random string for some purposes. Well, I do need this random string for a project of my friend. So, how do I create this random string? The idea is simple, I just need to create this random string from MD5 hashes that came from current time and multiply it by random integer and multiply again by some integer.

MD5 md5 = new MD5();
Date date = new Date();
long seed = date.getTime();
seed = seed * (1 + (int)(Math.random() * 5000));
hash = md5.asHex().toUpperCase();
int startIndex = 1 + (int)(Math.random() * 50);
if(((startIndex + passwordLength) - 1) > hash.length()){
startIndex = hash.length() - passwordLength;
returnValue = hash.substring(startIndex - 1, (startIndex - 1) + passwordLength);

As For the MD5, I use a library from FastMD5. And this is my code. Well, it’s a non optimized code. But, you should get the point.
Continue reading “Creating Random Password in JAVA”