30 April, 2015

How to print time from java date using jodatime library ?

package com.javadevelopersguide;

import java.util.Date;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

public class FormatJavaDateJoda {

/**
* Get Time from Java Date
*/
public static void main(String[] args) {
Date date=new Date();
System.out.println("Before Formatting:::::::::"+date);
DateTimeFormatter format=DateTimeFormat.forPattern("hh:mm:ss a");
String time=format.print(new DateTime(date));
System.out.println("After Formatting::::::::::"+time);
}

}


Output :- 

Before Formatting:::::::::Thu Apr 30 21:52:19 EST 2015
After Formatting::::::::::09:52:19 PM

Find more jodatime format from site.




29 April, 2015

Error: Could not find or load main class

This is the common issue with Eclipse , even I faced many times . This is not related to Eclipse or any other IDE tool.


This issue occurs when you are trying to run your main() method with respective class, its looking for the exact .class file in the class path.During the execution the .class file is not available in the class path. The best way to resolve this is, add the .class file into classpath.

There are many possible diagnosis you can do in your Eclipse for this issue. As per the Eclipse behaviour when you are updating the classpath (Build Path) , your class is getting compiled that time and the .class file got created. So, Be careful when doing the build path for your project.

Also check your Build Path, if any jar file is missing. Because, its might causes sometime.

In my case I just found the jar file missing in the build path , and I removed the missing jar and added new jar file from other location.Then executed my class with main method and it works. Below screenshot shows my issue.............






Hope it will help you.



Follow for more details on Google+ and @Facebook!!!

Find More Issues & Solutions -