<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>KosherJava &#187; Java</title>
	<atom:link href="http://www.kosherjava.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kosherjava.com</link>
	<description>A weblog about Zmanim, Kosher Coffee (Kosher Java) and other odds &#38; ends</description>
	<lastBuildDate>Fri, 06 Jan 2012 18:28:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>FAQ: Outputting Zmanim for A Different Time Zone With the the Zmanim API</title>
		<link>http://www.kosherjava.com/2011/11/08/outputting-zmanim-for-a-different-time-zone-with-the-the-zmanim-api/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=outputting-zmanim-for-a-different-time-zone-with-the-the-zmanim-api</link>
		<comments>http://www.kosherjava.com/2011/11/08/outputting-zmanim-for-a-different-time-zone-with-the-the-zmanim-api/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 05:01:03 +0000</pubDate>
		<dc:creator>KosherJava</dc:creator>
				<category><![CDATA[Software Dev]]></category>
		<category><![CDATA[Zmanim]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[FAQ]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Bugs]]></category>
		<category><![CDATA[Timezone]]></category>

		<guid isPermaLink="false">http://www.kosherjava.com/?p=1349</guid>
		<description><![CDATA[Question:Why does the output of zmanim for a different time zone appear incorrect?Answer: One of the common issues encountered by developers using the API is that zmanim generated for a different time zone than the user&#8217;s time zone may return output that appears incorrect. For example a user in Lakewood, NJ trying to calculate sunrise [...]]]></description>
			<content:encoded><![CDATA[<img class="alignleft" src="/images/coffeeQuestion.jpg" alt="Zmanim API FAQ"/><h2>Question:</h2>Why does the output of zmanim for a different time zone appear incorrect?<h2>Answer:</h2>
One of the common issues encountered by developers using the API is that zmanim generated for a different time zone than the user&#8217;s time zone may return output that appears incorrect. For example a user in Lakewood, NJ trying to calculate sunrise for Yerushalayim may attempt to use the following code:

<pre class="brush: java; title: ; notranslate">
String locationName = &quot;Jerusalem&quot;;
double latitude = 31.778; // Har habayis
double longitude = 35.2354;// Har Habayis
double elevation = 0;
TimeZone timeZone = TimeZone.getTimeZone(&quot;Asia/Jerusalem&quot;);
GeoLocation location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
ZmanimCalendar zc = new ZmanimCalendar(location);
zc.getCalendar().set(2011, Calendar.FEBRUARY, 8);
System.out.println(&quot;Sunrise: &quot; + zc.getSunrise());
System.out.println(&quot;Sunset: &quot; + zc.getSunset());
</pre>

While you would expect a <a href="http://www.kosherjava.com/maps/zmanim.html?lat=31.778&#038;lng=35.2354&#038;zoom=19&#038;date=2011-2-8">sunrise of 6:27:41 AM and sunset of 5:19:19 PM</a>, running this code on a computer anywhere in the Eastern Standard time zone would generate the following time that appears to be 7 hours early:
<pre class="brush: plain; title: ; notranslate">
Sunrise: Mon Feb 07 23:27:41 EST 2011
Sunset: Tue Feb 08 10:19:19 EST 2011
</pre>

The issue is simple, and the sunrise and sunset returned above are actually accurate. Zmanim are returned by the Zmanim API as a Java <a href="http://download.oracle.com/javase/7/docs/api/java/util/Date.html">Date object</a> that represents a moment in time (stored internally by Java as <a href="http://en.wikipedia.org/wiki/Unix_time">Unix Time</a> &#8211; the number of milliseconds since the January 1, 1970 GMT). Sunrise in Yerushalayim on February 8th actually happens at 11:27:41 PM on February 7th <b>EST</b>. Java is simply outputting the <a href="http://download.oracle.com/javase/7/docs/api/java/util/Date.html#toString%28%29">Date as a String</a> formatted to the users default time zone (EST in this example). The user probably intends to output the time in IST &#8211; Israel Standard Time (&#8220;Asia/Jerusalem&#8221; in the Olson database). To do this you have to output the zmanim using a formatter set to use the &#8220;Asia/Jerusalem&#8221; time zone.

<pre class="brush: java; title: ; notranslate">
DateFormat zmanimFormat = new SimpleDateFormat(&quot;EEE MMM dd HH:mm:ss z yyyy&quot;);
zmanimFormat.setTimeZone(location.getTimeZone());

System.out.println(&quot;sunrise: &quot; + zmanimFormat.format(zc.getSunrise()));
System.out.println(&quot;sunset:&quot; + zmanimFormat.format(zc.getSunset()));
</pre>
will output the expected
<pre class="brush: plain; title: ; notranslate">
sunrise: Tue Feb 08 06:27:41 IST 2011
sunset:Tue Feb 08 17:19:19 IST 2011
</pre>

Below is the full code example. 

<pre class="brush: java; highlight: [16,17,18,19]; title: ; notranslate">
import net.sourceforge.zmanim.*;
import net.sourceforge.zmanim.util.*;
import java.util.TimeZone;
public class FormatZmanim{
	public static void main(String [] args) {
		String locationName = &quot;Jerusalem&quot;;
		double latitude = 31.778; //latitude of Har habayis
		double longitude = 35.2354; //longitude of Har Habayis
		double elevation = 0; //optional elevation
		//use a Valid Olson Database timezone listed in java.util.TimeZone.getAvailableIDs()
		TimeZone timeZone = TimeZone.getTimeZone(&quot;Asia/Jerusalem&quot;);
		//create the location object
		GeoLocation location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
		ZmanimCalendar zc = new ZmanimCalendar(location); //create the ZmanimCalendar
		zc.getCalendar().set(2011, Calendar.FEBRUARY, 8); //set the date
		DateFormat zmanimFormat = new SimpleDateFormat(&quot;EEE MMM dd HH:mm:ss z yyyy&quot;); //Create the formatter
		zmanimFormat.setTimeZone(location.getTimeZone()); //set the formatter's time zone
		System.out.println(&quot;sunrise: &quot; + zmanimFormat.format(zc.getSunrise()));
		System.out.println(&quot;sunset:&quot; + zmanimFormat.format(zc.getSunset()));
	}
}
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.kosherjava.com/2011/11/08/outputting-zmanim-for-a-different-time-zone-with-the-the-zmanim-api/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Zmanim API Ported to Cocoa / Objective-C</title>
		<link>http://www.kosherjava.com/2011/07/29/zmanim-api-ported-to-cocoa-objective-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=zmanim-api-ported-to-cocoa-objective-c</link>
		<comments>http://www.kosherjava.com/2011/07/29/zmanim-api-ported-to-cocoa-objective-c/#comments</comments>
		<pubDate>Fri, 29 Jul 2011 16:48:25 +0000</pubDate>
		<dc:creator>KosherJava</dc:creator>
				<category><![CDATA[Software Dev]]></category>
		<category><![CDATA[Zmanim]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Cocoa API]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[port]]></category>

		<guid isPermaLink="false">http://www.kosherjava.com/?p=875</guid>
		<description><![CDATA[Moshe Berman completed the 2.0 release of his port of the KosherJava Zmanim API from Java to a Cocoa API using Objective-C. You can see the work in the KosherCocoa project page. The original work on the port dates back to Moshe&#8217;s iPhone Ultimate Omer 2 (iTunes link) app. In that app, he ported the [...]]]></description>
			<content:encoded><![CDATA[<img class="alignleft" src="/images/PortCityJava240.jpg" alt="Port City Java" title="Port City Java" /><a href="http://www.mosheberman.com">Moshe Berman</a> completed the 2.0 release of his port of the KosherJava <a href="http://www.kosherjava.com/zmanim-project/">Zmanim API</a> from Java to a <a href="http://en.wikipedia.org/wiki/Cocoa_%28API%29">Cocoa API</a> using <a href="http://en.wikipedia.org/wiki/Objective-C">Objective-C</a>. You can see the work in the <a href="https://github.com/MosheBerman/KosherCocoa">KosherCocoa</a> project page. The original work on the port dates back to Moshe&#8217;s iPhone <a href="http://mosheberman.com">Ultimate Omer 2</a> (<a href="http://itunes.com/apps/mosheberman/sefira">iTunes link</a>) app. In that app, he ported the minimum amount of code needed to calculate sunset in order to roll the day of the Omer after sunset. With Moshe&#8217;s latest check-in at <a href= "https://github.com">github</a>, he provided a port of a good portion of the API sticking to the basic design of the KosherJava API. The complexZmanimCalendar still remains to be ported, but the majority of zmanim in common use are in the ported ZmanimCalendar. Moshe&#8217;s blog post <a href="http://mosheberman.com/wordpress/2011/07/25/koshercocoa-2-0/">Introducing KosherCocoa 2.0</a> has additional details. Additional developer notes can be seen in the <a href="https://github.com/MosheBerman/KosherCocoa/wiki">KosherCocoa wiki page</a>. This port will be a boon to <a href="http://en.wikipedia.org/wiki/IOS_%28Apple%29">iOS</a> developers who now have a simple way to include zmanim in their iPhone and iPad apps.
Here is some sample code that outputs zmanim to the <a href="http://en.wikipedia.org/wiki/Console_%28Mac_OS_X%29">console</a>.

<h3>Zmanim.m</h3>
<pre class="brush: objc; highlight: [24,25,26,27]; title: ; notranslate">
#import &lt;Foundation/Foundation.h&gt;
#import &quot;ZmanimCalendar.h&quot;

int main (int argc, const char * argv[]){

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    //  Set up the location
    NSString *locationName = @&quot;Lakewood, NJ&quot;;
    double latitude = 40.096; //Lakewood, NJ
    double longitude = -74.222; //Lakewood, NJ
    NSTimeZone *timeZone = [NSTimeZone timeZoneForSecondsFromGMT:-18000];

    //  Initialize the Zmanim Calendar
    GeoLocation *geoLocation = [[GeoLocation alloc] initWithName:locationName andLatitude:latitude andLongitude:longitude andTimeZone:timeZone];
    ZmanimCalendar *zmanimCalendar = [[ZmanimCalendar alloc] initWithLocation:geoLocation];

    //  Create a Formatter for the date information
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setTimeZone:timeZone];
    [formatter setDateStyle:NSDateFormatterNoStyle];
    [formatter setTimeStyle:NSDateFormatterMediumStyle];

    NSDate *sunrise = [zmanimCalendar sunrise];
    NSDate *sofZmanShmaMGA = [zmanimCalendar sofZmanShmaMogenAvraham];
    NSDate *sofZmanShmaGRA = [zmanimCalendar sofZmanShmaGra];
    NSDate *sunset = [zmanimCalendar sunset];

    NSLog(@&quot;Today's Zmanim for %@&quot;,  [geoLocation locationName]);
    NSLog(@&quot;Sunrise: %@&quot;,  [formatter stringFromDate:sunrise]);
    NSLog(@&quot;Sof Zman Shema MGA: %@&quot;,  [formatter stringFromDate:sofZmanShmaMGA]);
    NSLog(@&quot;Sof Zman Shema GRA: %@&quot;,  [formatter stringFromDate:sofZmanShmaGRA]);
    NSLog(@&quot;Sunset: %@&quot;,  [formatter stringFromDate:sunset]);

    [pool drain];
    return 0;
}
</pre>

This would output (on February 8th):
<pre class="brush: plain; title: ; notranslate">
Today's Zmanim for Lakewood, NJ
Sunrise: 6:58:43 AM
Sof Zman Shema MGA: 8:59:04 AM
Sof Zman Shema GRA: 9:35:04 AM
Sunset: 5:24:09 PM
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.kosherjava.com/2011/07/29/zmanim-api-ported-to-cocoa-objective-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>KosherJava Zmanim API Released Under the LGPL License</title>
		<link>http://www.kosherjava.com/2011/05/09/kosherjava-zmanim-api-released-under-the-lgpl-license/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=kosherjava-zmanim-api-released-under-the-lgpl-license</link>
		<comments>http://www.kosherjava.com/2011/05/09/kosherjava-zmanim-api-released-under-the-lgpl-license/#comments</comments>
		<pubDate>Mon, 09 May 2011 20:43:23 +0000</pubDate>
		<dc:creator>KosherJava</dc:creator>
				<category><![CDATA[Site News]]></category>
		<category><![CDATA[Software Dev]]></category>
		<category><![CDATA[Zmanim]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[GPL]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[LGPL]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[port]]></category>

		<guid isPermaLink="false">http://www.kosherjava.com/?p=879</guid>
		<description><![CDATA[Until this point the KosherJava Zmanim API has been released under the GPL V2.0 open source license. This had the effect of forcing any application written using the library to release it&#8217;s source code under the same license. Being that the Zmanim API is a library, the LGPL is a more appropriate license. The LGPL [...]]]></description>
			<content:encoded><![CDATA[<img class="alignleft" src="/images/lgpl.png" alt="LGPL"/>Until this point the <a href="http://www.kosherjava.com/zmanim-project/">KosherJava Zmanim API</a> has been released under the <a href="http://en.wikipedia.org/wiki/GNU_General_Public_License">GPL</a>  <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">V2.0</a> <a href="http://en.wikipedia.org/wiki/Open-source_license"> open source license</a>. This had the effect of forcing any application written using the library to release it&#8217;s source code under the same license. Being that the Zmanim <a href="http://en.wikipedia.org/wiki/API">API</a> is a <a href="http://en.wikipedia.org/wiki/Library_%28computing%29">library</a>, the <a href="http://en.wikipedia.org/wiki/LGPL">LGPL</a> is a more appropriate license. The LGPL allows developers to use the KosherJava Zmanim API, yet keep their application code <a href="http://en.wikipedia.org/wiki/Proprietary_software">closed source</a>. Only changes to the API itself (such as ports to different languages) would have to be released as open source. I had in the past on request released the source under the LGPL (the <a href="http://www.kosherjava.com/2010/04/20/zmanim-api-ported-to-net-c/">Zmanim API .NET port</a> has already been released under the LGPL with my permission), and with the recent 3/27/2011 <a href="http://www.kosherjava.com/2011/03/23/zmanim-api-in-svn/">SVN checkin</a> I formally changed the Java Zmanim API license to the <a href="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL 2.1</a> (not the newer <a href="http://www.gnu.org/copyleft/lesser.html">LGPL 3.0</a>). The next 1.3.0 release will be the first formal release under the LGPL. In one case the change to the license required permission from developer who wrote code used by the the Zmanim API, and this was done.]]></content:encoded>
			<wfw:commentRss>http://www.kosherjava.com/2011/05/09/kosherjava-zmanim-api-released-under-the-lgpl-license/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Calculating Erev Pesach Zmanim</title>
		<link>http://www.kosherjava.com/2011/04/14/calculating-erev-pesach-zmanim/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=calculating-erev-pesach-zmanim</link>
		<comments>http://www.kosherjava.com/2011/04/14/calculating-erev-pesach-zmanim/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 03:20:32 +0000</pubDate>
		<dc:creator>KosherJava</dc:creator>
				<category><![CDATA[Software Dev]]></category>
		<category><![CDATA[Zmanim]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Jewish Calendar]]></category>
		<category><![CDATA[Pesach]]></category>

		<guid isPermaLink="false">http://www.kosherjava.com/?p=950</guid>
		<description><![CDATA[The Zmanim API did not have dedicated zmanim to claculate the Erev Pesach zmanim of sof zman achilas chametz (the latest time one can eat chametz), and sof zman biur chametz (the latest time to burn chametz) till the April 14 check in to the KosherJava Zmanim Project SVN repository. The latest time for eating [...]]]></description>
			<content:encoded><![CDATA[<img class="alignleft" src="/images/matzah.jpg" alt="Matzah"/>The Zmanim API did not have dedicated zmanim to claculate the Erev Pesach zmanim of <em>sof zman achilas <a href="http://en.wikipedia.org/wiki/Chametz">chametz</a></em> (the latest time one can eat chametz), and sof zman <a href="http://en.wikipedia.org/wiki/Chametz#Removal_of_chametz">biur chametz</a> (the latest time to burn chametz) till the <a href="https://code.google.com/p/kosherjava/source/detail?r=42">April 14 check in</a> to the <a href="https://code.google.com/p/kosherjava/">KosherJava Zmanim Project SVN repository</a>. The latest time for eating chametz is at the end of the 4th hour of the day. This corresponds to sof zman tfila. The API has about 12 of those, so that does not require any special programming, but to help developers who are unaware of how they work I created 3 wrapper getSofZmanAchilasChametz methods (<a href="http://www.kosherjava.com/zmanim/docs/api/net/sourceforge/zmanim/ComplexZmanimCalendar.html#getSofZmanAchilasChametzGRA%28%29">getSofZmanAchilasChametzGRA()</a>, <a href="http://www.kosherjava.com/zmanim/docs/api/net/sourceforge/zmanim/ComplexZmanimCalendar.html#getSofZmanAchilasChametzMGA72Minutes%28%29">getSofZmanAchilasChametzMGA72Minutes()</a> and <a href="http://www.kosherjava.com/zmanim/docs/api/net/sourceforge/zmanim/ComplexZmanimCalendar.html#getSofZmanAchilasChametzMGA16Point1Degrees%28%29">getSofZmanAchilasChametzMGA16Point1Degrees()</a>) calling the 3 most commonly used getSofZmanTfila methods (getSofZmanTfilaGRA(), getSofZmanTfilaMGA72Minutes() and getSofZmanTfilaMGA16Point1Degrees()). For example here is the exact code used in getSofZmanAchilasChametzGRA()
<pre class="brush: java; title: ; notranslate">
public Date getSofZmanAchilasChametzGRA() {
	return getSofZmanTfilaGRA();
}
</pre>

The API itself is very flexible, and as long as you know the calculation of the zman, you can easily calculate it. For example, to calculate sof zman biur chametz according to the <a href="http://en.wikipedia.org/wiki/Vilna_Gaon">GR&quot;A</a>, the time would be 5 shaos zmaniyos after sunrise. Using the Zmanim API this would be coded as:
<pre class="brush: java; title: ; notranslate">
Date SofZmanBiurChametzGra = getTimeOffset(getSeaLevelSunrise(), getShaahZmanisGra() * 5);
</pre> 
The exact code used in the API is:
<pre class="brush: java; title: ; notranslate">
public Date getSofZmanBiurChametzGRA() {
	return getTimeOffset(getSeaLevelSunrise(), getShaahZmanisGra() * 5);
}
</pre>
Developers who want to use the current API to generate these zmanim can use the following sample as a guide.
<pre class="brush: java; highlight: [11,12,13,14,15,16]; title: ; notranslate">
String locationName = &quot;Lakewood, NJ&quot;;
double latitude = 40.09596; //Lakewood, NJ
double longitude = -74.22213; //Lakewood, NJ
double elevation = 0; //optional elevation
TimeZone timeZone = TimeZone.getTimeZone(&quot;America/New_York&quot;);
GeoLocation location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
ComplexZmanimCalendar czc = new ComplexZmanimCalendar(location);
czc.getCalendar().set(Calendar.YEAR, 2011);
czc.getCalendar().set(Calendar.MONTH, Calendar.APRIL);
czc.getCalendar().set(Calendar.DAY_OF_MONTH, 18);
Date graAchilas = czc.getSofZmanTfilaGRA();
Date graBiur = czc.getTimeOffset(czc.getSeaLevelSunrise(), czc.getShaahZmanisGra() * 5);
Date mga72Achilas = czc.getSofZmanTfilaMGA72Minutes();
Date mga72Biur = czc.getTimeOffset(czc.getAlos72(), czc.getShaahZmanisMGA() * 5);
Date mga16Achilas = czc.getSofZmanTfilaMGA16Point1Degrees();
Date mga16Biur = czc.getTimeOffset(czc.getAlos16Point1Degrees(), czc.getShaahZmanis16Point1Degrees() * 5);
System.out.println(&quot;Erev Pesach Zmanim for &quot; + locationName);
System.out.println(&quot;Sof Zman Achilas Chametz GRA: &quot; + graAchilas);
System.out.println(&quot;Sof Zman Biur Chametz GRA: : &quot; + graBiur);
System.out.println(&quot;Sof Zman Achilas Chametz MGA 72 Minutes: &quot; + mga72Achilas);
System.out.println(&quot;Sof Zman Biur Chametz MGA 72 Minutes: &quot; + mga72Biur);
System.out.println(&quot;Sof Zman Achilas Chametz MGA 16.1 Deg: &quot; + mga16Achilas);
System.out.println(&quot;Sof Zman Biur Chametz MGA 16.1 Deg: &quot; + mga16Biur);
</pre>

this would output

<pre class="brush: plain; title: ; notranslate">
C:\path\to\code&gt;javac ErevPesachZmanim.java

C:\path\to\code&gt;java ErevPesachZmanim

Erev Pesach Zmanim for Lakewood, NJ
Sof Zman Achilas Chametz GRA: Mon Apr 18 10:42:42 EDT 2011
Sof Zman Biur Chametz GRA: : Mon Apr 18 11:49:39 EDT 2011
Sof Zman Achilas Chametz MGA 72 Minutes: Mon Apr 18 10:18:42 EDT 2011
Sof Zman Biur Chametz MGA 72 Minutes: Mon Apr 18 11:37:39 EDT 2011
Sof Zman Achilas Chametz MGA 16.1 Deg: Mon Apr 18 10:13:56 EDT 2011
Sof Zman Biur Chametz MGA 16.1 Deg: Mon Apr 18 11:35:18 EDT 2011
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.kosherjava.com/2011/04/14/calculating-erev-pesach-zmanim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zmanim API Ported to .NET (C#)</title>
		<link>http://www.kosherjava.com/2010/04/20/zmanim-api-ported-to-net-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=zmanim-api-ported-to-net-c</link>
		<comments>http://www.kosherjava.com/2010/04/20/zmanim-api-ported-to-net-c/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 04:07:08 +0000</pubDate>
		<dc:creator>KosherJava</dc:creator>
				<category><![CDATA[Software Dev]]></category>
		<category><![CDATA[Zmanim]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.kosherjava.com/?p=514</guid>
		<description><![CDATA[Yitzchok ported the Zmanim API from Java to a .NET API using C#. The Zmanim .NET project was released under the LGPL. This is a change from the GPL used by the Java API, something that may change shortly. Also part of the project was the creation of a C# version of the Zmanim CLI, [...]]]></description>
			<content:encoded><![CDATA[<img class="alignleft" src="/images/PortCityJava240.jpg" alt="Port City Java" title="Port City Java" /><a href="http://twitter.com/yitzchok">Yitzchok</a> ported the <a href="http://www.kosherjava.com/zmanim-project/">Zmanim API</a> from Java to a <a href="http://en.wikipedia.org/wiki/.NET_Framework">.NET</a> API using <a href="http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29">C#</a>. The <a href="http://github.com/Yitzchok/Zmanim/">Zmanim .NET project</a> was <a href="http://github.com/Yitzchok/Zmanim/downloads">released</a> under the <a href="http://www.gnu.org/licenses/lgpl.html">LGPL</a>. This is a change from the <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt">GPL</a> used by the Java <a href="http://en.wikipedia.org/wiki/Application_programming_interface">API</a>, something that may change shortly. Also part of the project was the creation of a C# version of the Zmanim <a href="http://en.wikipedia.org/wiki/Command-line_interface">CLI</a>, matching <a href="http://dosilinux.wordpress.com/">Moshe Wagner&#8217;s</a> <a href="http://www.kosherjava.com/2009/11/21/zmanimcli-command-line-interface/">Java Zmanim CLI</a>. When developing the project, Yitzchok created the <a href="http://gist.github.com/360934">ZmanimTest</a> <a href="http://www.junit.org">JUnit</a> test case class to confirm that the C# port output matched the Java API. I will likely add this to the core Zmanim API in the near future. <span style="text-decoration: line-through;">The port currently relies on <a href="http://www.ikvm.net/">IKVM</a> assemblies as can be seen in the Java references in the code sample below, mostly because of the lack of a native .NET equivalent of the Java <a href="http://java.sun.com/javase/7/docs/api/java/util/TimeZone.html">TimeZone class</a></span>. Yitzchok also created some <a href="http://github.com/Yitzchok/Zmanim/tree/master/Samples/">examples of the use of the Zmanim .NET API</a> that will be of help to developers. Below are two of the simpler examples in C# and <a href="http://en.wikipedia.org/wiki/Visual_Basic_.NET">VB.NET</a> demonstrating a very simple use of the API to output zmanim from the console.
<h3>C#</h3>
<pre class="brush: csharp; title: ; notranslate">
using Zmanim.TimeZone;
using Zmanim.TzDatebase; //in Zmanim.TzDatebase.dll assembly
using Zmanim.Utilities;

namespace Zmanim.Samples.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            string locationName = &quot;Lakewood, NJ&quot;;
            double latitude = 40.09596; //Lakewood, NJ
            double longitude = -74.22213; //Lakewood, NJ
            double elevation = 0; //optional elevation
            ITimeZone timeZone = new OlsonTimeZone(&quot;America/New_York&quot;);
            GeoLocation location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
            ComplexZmanimCalendar zc = new ComplexZmanimCalendar(location);
            //optionally set it to a specific date with a year, month and day
            //ComplexZmanimCalendar zc = new ComplexZmanimCalendar(new DateTime(1969, 2, 8), location);

            System.Console.WriteLine(&quot;Today's Zmanim for &quot; + locationName);
            System.Console.WriteLine(&quot;Sunrise: &quot; + zc.GetSunrise()); //output sunrise
            System.Console.WriteLine(&quot;Sof Zman Shema MGA: &quot; + zc.GetSofZmanShmaMGA()); //output Sof Zman Shema MGA
            System.Console.WriteLine(&quot;Sof Zman Shema GRA: &quot; + zc.GetSofZmanShmaGRA()); //output Sof Zman Shema GRA
            System.Console.WriteLine(&quot;Sunset: &quot; + zc.GetSunset()); //output sunset

            System.Console.WriteLine(&quot;Press enter to exit.&quot;);
            System.Console.ReadLine();
        }
    }
}
</pre>
<h3>VB.NET</h3>
<pre class="brush: vb; title: ; notranslate">
mports Zmanim.TzDatebase 'in Zmanim.TzDatebase.dll assembly
Imports Zmanim.Utilities
Imports Zmanim.TimeZone

Module Module1

    Sub Main()
        Dim locationName As String = &quot;Lakewood, NJ&quot;
        Dim latitude As Double = 40.09596 'Lakewood, NJ
        Dim longitude As Double = -74.22213 'Lakewood, NJ
        Dim elevation As Double = 0 'optional elevation
        Dim timeZone As ITimeZone = New OlsonTimeZone(&quot;America/New_York&quot;)
        Dim location As New GeoLocation(locationName, latitude, longitude, elevation, timeZone)
        Dim zc As New ComplexZmanimCalendar(location)
        'optionally set it to a specific date with a year, month and day
        'Dim zc As New ComplexZmanimCalendar(New DateTime(1969, 2, 8), location)
        System.Console.WriteLine(&quot;Today's Zmanim for &quot; &amp; locationName)
        System.Console.WriteLine(&quot;Sunrise: &quot; &amp; zc.GetSunrise().ToString)
        'output sunrise
        System.Console.WriteLine(&quot;Sof Zman Shema MGA: &quot; &amp; zc.GetSofZmanShmaMGA().ToString)
        'output Sof Zman Shema MGA
        System.Console.WriteLine(&quot;Sof Zman Shema GRA: &quot; &amp; zc.GetSofZmanShmaGRA().ToString)
        'output Sof Zman Shema GRA
        System.Console.WriteLine(&quot;Sunset: &quot; &amp; zc.GetSunset().ToString)
        'output sunset
        System.Console.WriteLine(&quot;Press enter to exit.&quot;)
        System.Console.ReadLine()

    End Sub

End Module
</pre>
The current Zmanim .NET TODO list for the project includes:
<ul>
<li style="text-decoration: line-through;">Remove dependency to Java (IKVM assemblies)</li>
<li>The API should follow the <a href="http://msdn.microsoft.com/en-us/library/ms229042.aspx">.NET guidelines</a></li>
<li>Make it <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query">Linq</a> friendly</li>
<li>Add examples how to use this project in a ASP.NET MVC site and WPF Application</li>
<li style="text-decoration: line-through;">Try to get it to work on <a href="http://www.silverlight.net/">Silverlight</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.kosherjava.com/2010/04/20/zmanim-api-ported-to-net-c/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Android Zmanim Using the KosherJava Zmanim API</title>
		<link>http://www.kosherjava.com/2010/04/19/android-zmanim-using-the-zmanim-api/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=android-zmanim-using-the-zmanim-api</link>
		<comments>http://www.kosherjava.com/2010/04/19/android-zmanim-using-the-zmanim-api/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 04:49:39 +0000</pubDate>
		<dc:creator>KosherJava</dc:creator>
				<category><![CDATA[Software Dev]]></category>
		<category><![CDATA[Zmanim]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.kosherjava.com/?p=462</guid>
		<description><![CDATA[There are various software projects using the KosherJava Zmanim API. One of the active ones is Jay Gindin&#8217;s open source Android Zmanim app for the Android platform. Activity in the project is constant. The upcoming version allows the selection of a specific calculation for zmanim you want such as the zman Talis/Tefilin pictured here. There [...]]]></description>
			<content:encoded><![CDATA[<img class="alignleft" src="/images/AndroidZmanim.png" alt="Android Zmanim" title="Android Zmanim" />There are various software projects using the KosherJava Zmanim API. One of the active ones is Jay Gindin&#8217;s open source <a href="http://code.google.com/p/android-zmanim">Android Zmanim</a> app for the <a href="http://www.android.com/">Android platform</a>. Activity in the project is constant. The upcoming version allows the selection of a specific calculation for zmanim you want such as the zman Talis/Tefilin pictured here. There are plans to add direction to Yerushalayim functionality using the Zmanim API. (For more information on calculating bearing using the API, see <a href="http://www.kosherjava.com/2009/11/29/calculating-the-bearing-to-har-habayis-using-the-zmanim-api/">Calculating the Bearing/Direction to Har Habayis Using the Zmanim API</a> article.) A large part of Jay&#8217;s motivations for developing the code was lezecher nishmas his nephew Shemuel Reuven ben Yehudit Rachel who, lost his battle with cancer on October 21, 2009. The one very minor issue Jay had with the API (and documentation) was the <a href="http://en.wikipedia.org/wiki/Ashkenazi_Jews">Ashkenazi</a> spelling of the zmanim names, something that as an Ashekenazi I do not plan to change <img src='http://www.kosherjava.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , but as you can see his Android Zmanim front end used <a href="http://en.wikipedia.org/wiki/Sephardi_Jews">Sephardi</a> labeling. Asked how he found the project, he answered with the typical answer to this question <blockquote>I Googled around, and found your project.</blockquote> One of my goals with the API was to make it easy for developers to use and port. This was confirmed by Jay <blockquote>I found it to be very easy to pull into my app, even on Android&#8230;no changes necessary, not even a recompile</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.kosherjava.com/2010/04/19/android-zmanim-using-the-zmanim-api/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Calculating the Bearing/Direction to Har Habayis Using the Zmanim API</title>
		<link>http://www.kosherjava.com/2009/11/29/calculating-the-bearing-to-har-habayis-using-the-zmanim-api/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=calculating-the-bearing-to-har-habayis-using-the-zmanim-api</link>
		<comments>http://www.kosherjava.com/2009/11/29/calculating-the-bearing-to-har-habayis-using-the-zmanim-api/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 04:28:14 +0000</pubDate>
		<dc:creator>KosherJava</dc:creator>
				<category><![CDATA[Software Dev]]></category>
		<category><![CDATA[Zmanim]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Davening]]></category>
		<category><![CDATA[geoid]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[Great Circle]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Rhumb Line]]></category>
		<category><![CDATA[WGS84]]></category>

		<guid isPermaLink="false">http://www.kosherjava.com/?p=322</guid>
		<description><![CDATA[An earlier &#8220;Bearing to Yerushalayim and Zmanim Map&#8221; post demonstrated the use of JavaScript to render the bearing to Har Habayis on a Google Map. A more detailed follow-up post &#8220;Technical Information about the Bearing to Yerushalayim Map&#8221; dealt with detailed technical information on these calculations. The main Bearing to Yerushalayim and Zmanim Map page [...]]]></description>
			<content:encoded><![CDATA[<img class="alignleft" src="/images/javaDir.png" alt="Java direction"/>An earlier <a href="http://www.kosherjava.com/2007/12/30/bearing-to-yerushalayim-and-zmanim-map/">&#8220;Bearing to Yerushalayim and Zmanim Map&#8221;</a> post demonstrated the use of JavaScript to render the bearing to <a href="http://en.wikipedia.org/wiki/Temple_Mount">Har Habayis</a> on a <a href="http://www.kosherjava.com/maps/zmanim.html">Google Map</a>. A more detailed follow-up post <a href="http://www.kosherjava.com/2008/04/07/technical-information-about-the-bearing-to-yerushalayim-map/">&#8220;Technical Information about the Bearing to Yerushalayim Map&#8221;</a> dealt with detailed technical information on these calculations. The main <a href="http://www.kosherjava.com/zmanim-project/bearing-to-yerushalayim-and-zmanim-map/">Bearing to Yerushalayim and Zmanim Map</a> page usually has the most up to date information on the subject. What was not detailed in previously published posts and pages was that most of the calculations available via <a href="http://en.wikipedia.org/wiki/Javascript">JavaScript</a> are now in the core <a href="http://www.kosherjava.com/zmanim-project/">Zmanim API</a>. Available since the July, 2008 <a href="http://www.kosherjava.com/2008/07/17/zmanim-api-11-beta-2-released/">beta 2 release</a> of <a href="http://www.kosherjava.com/zmanim-project/downloads/">version 1.1</a> is the ability to bearings/directions using both the <a href="http://en.wikipedia.org/wiki/Great_circle">great circle</a> and <a href="http://en.wikipedia.org/wiki/Rhumb_line">rhumb line</a> methods in <a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29">Java</a>. The <a href="http://www.kosherjava.com/zmanim/docs/api/net/sourceforge/zmanim/util/GeoLocation.html">GeoLocation Object</a> was modified to calculate the great circle bearings (both <a href="http://www.kosherjava.com/zmanim/docs/api/net/sourceforge/zmanim/util/GeoLocation.html#getGeodesicInitialBearing(net.sourceforge.zmanim.util.GeoLocation)">initial</a> and <a href="http://www.kosherjava.com/zmanim/docs/api/net/sourceforge/zmanim/util/GeoLocation.html#getGeodesicFinalBearing%28net.sourceforge.zmanim.util.GeoLocation%29">final</a>), and <a href="http://www.kosherjava.com/zmanim/docs/api/net/sourceforge/zmanim/util/GeoLocation.html#getRhumbLineBearing%28net.sourceforge.zmanim.util.GeoLocation%29">rhumb line bearing</a> from any GeoLocation Object to another. In addition, distance calculation between the two points using both of these line types is supported. What was not <a href="http://en.wikipedia.org/wiki/Porting">ported</a> from the JavaScript version was the less accurate <a href="http://en.wikipedia.org/wiki/Haversine_formula">Haversine formula</a>, or the simpler <a href="http://en.wikipedia.org/wiki/Spherical_trigonometry">spherical law of cosines</a> algorithms that yield identical results. Instead, the Zmanim API uses the far more accurate Vincenty formulae using the <a href="http://en.wikipedia.org/wiki/WGS84">WGS84</a> <a href="http://en.wikipedia.org/wiki/Geoid">geoid</a> model of the earth. Published by the geodesist/mathematician <a href="http://en.wikipedia.org/wiki/Thaddeus_Vincenty">Thaddeus Vincenty</a>, it is said to be accurate to about one-half millimeter, more than adequate for our calculation. The code in the API is a Java port of the previously published, slightly <a href="http://www.kosherjava.com/maps/glatlng.js">modified</a> version of <a href="http://www.movable-type.co.uk/">Chris Veness&#8217;s</a>  <a href="http://www.movable-type.co.uk/scripts/latlong-vincenty.html">JavaScript  implementation</a> . Below is a simple Java example of generating bearing and distances.

<pre class="brush: java; title: ; notranslate">
/**
 * This program demonstrates how to calculate bearing to Yerushalayim
 * using the kosherjava.com Zmanim API. Both the great circle and
 * rhumb line method are shown
 * To compile, ensure that the Zmanim Jar is in your classpath.
 */
import net.sourceforge.zmanim.util.GeoLocation;
import java.util.TimeZone;

public class BearingToYerushalayim{
	public static void main(String [] args) {
		GeoLocation lakewood = new GeoLocation(&quot;Lakewood, NJ&quot;, 40.09596, -74.22213, 0, TimeZone.getTimeZone(&quot;America/New_York&quot;));
		GeoLocation harHabayis = new GeoLocation(&quot;Har Habayis&quot;, 31.77805, 35.235149, 0, TimeZone.getTimeZone(&quot;Asia/Jerusalem&quot;));

		double greatCircleInitialBearing = lakewood.getGeodesicInitialBearing(harHabayis);
		double greatCircleDistance = lakewood.getGeodesicDistance(harHabayis);

		double rhumbLineBearing = lakewood.getGeodesicInitialBearing(harHabayis);
		double rhumbLineDistance = lakewood.getRhumbLineDistance(harHabayis);

		System.out.println(&quot;Great circle initial bearing: &quot; + greatCircleInitialBearing + &quot; degrees &quot;);
		System.out.println(&quot;Great circle distance: &quot; + greatCircleDistance/1000 + &quot; KM&quot;);

		System.out.println(&quot;Rhumb line bearing: &quot; + rhumbLineBearing + &quot; degrees&quot;);
		System.out.println(&quot;Rhumb line distance: &quot; + lakewood.getRhumbLineDistance(harHabayis)/1000 + &quot; KM&quot;);

	}
}
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.kosherjava.com/2009/11/29/calculating-the-bearing-to-har-habayis-using-the-zmanim-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZmanimCLI (Command Line Interface)</title>
		<link>http://www.kosherjava.com/2009/11/21/zmanimcli-command-line-interface/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=zmanimcli-command-line-interface</link>
		<comments>http://www.kosherjava.com/2009/11/21/zmanimcli-command-line-interface/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 04:52:50 +0000</pubDate>
		<dc:creator>KosherJava</dc:creator>
				<category><![CDATA[Software Dev]]></category>
		<category><![CDATA[Zmanim]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Cross Platform]]></category>
		<category><![CDATA[Hebrew Date]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.kosherjava.com/?p=241</guid>
		<description><![CDATA[Moshe Wagner who wrote the Zmanim GUI notified me in August that that he created a command line interface for zmanim using my Zmanim API. The technical approach of using reflection was similar to the way I used reflection in the Zmanim Clock Applet, but he took it to new heights. Sample use of accessing [...]]]></description>
			<content:encoded><![CDATA[Moshe Wagner who wrote the <a href="http://www.kosherjava.com/2009/03/14/zmanim-gui-released/">Zmanim GUI</a> notified me in August that that he created a <a href="http://en.wikipedia.org/wiki/Command-line_interface">command line interface</a> for zmanim using my <a href="http://www.kosherjava.com/zmanim-project/">Zmanim API</a>. The technical approach of using reflection was similar to the way I used reflection in the <a href="http://www.kosherjava.com/zmanim-project/zmanim-clock-applet/">Zmanim Clock Applet</a>, but he took it to new heights. Sample use of accessing zmanim using his CLI interface is:

<pre class="brush: plain; title: ; notranslate">moshe@debian:~/Desktop$ java -jar ZmanimCLI.jar sunrise
6:10:28</pre>

<pre class="brush: plain; title: ; notranslate">moshe@debian:~/Desktop$ java -jar ZmanimCLI.jar --date 2010/08/12 tzais72
20:38:15</pre>

<pre class="brush: plain; title: ; notranslate">moshe@debian:~/Desktop$ java -jar ZmanimCLI.jar
Usage: ZmanimCLI [options] [Time]

Options:
       -d      --date &lt;yyyy/mm/dd&gt;             Set date. (Year first!)
       -lat    --latitude &lt;latitude&gt;           Set location's latitude
       -lon    --longitude &lt;longitude&gt;         Set location's longitude
       -e      --elevation &lt;elevation&gt;         Set location's
elevation; Positive only
       -tz     --timezone &lt;timezone&gt;           Set location's TimeZone

Help:
       -h      --help                          Show this help
       -stl    --time-list                     Show common available
times to display
       -ftl    --full-time-list                Show all available
times to display
       -tzl    --timezone-list                 Show available timezones

Example:
       ZmanimCLI --latitude 31.7780 --longitude 35.235149 --elevation
600 --timezone Israel Sunrise
       Will show the sunrise time today in Jerusalem</pre>

While your first reaction may be that it is interesting in a theoretical geeky way, but has no practical value, I will quote Moshe&#8217;s explanation as to why it is useful:

<blockquote>Why is this useful?
Well, first of all it was a nice experiment. But mainly, you can now use Zmanim (although externally), via any language you want, no longer being tied to Java.</blockquote>

Months later, Moshe actually put this to practical use in his C++ based <a href="http://code.google.com/p/luach/">Luach</a> project. This Luach (similar to the known <a href="http://www.kaluach.com/">Kaluach</a>) uses the <a href="http://en.wikipedia.org/wiki/Qt_%28toolkit%29">Qt</a> framework. utilizing <a href="http://libhdate.sourceforge.net">libhdate</a> for the date stuff (something not offered by the Zmanim API, and the topic of a future <a href="http://www.kosherjava.com/tag/faq/">Zmanim API FAQ</a>), displaying zmanim using the Zmanim API via CLI for the zmanim calculations. While you would expect such an approach to be slow, using the Luach seemed almost instantaneous. I will post more about his Luach program (recently reviewed at <a href="http://kosherdev.com">KosherDev.com</a>) at some point in the future.]]></content:encoded>
			<wfw:commentRss>http://www.kosherjava.com/2009/11/21/zmanimcli-command-line-interface/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>FAQ: Where is the Zmanim API Main Method?</title>
		<link>http://www.kosherjava.com/2009/11/05/faq-where-is-the-main-method/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=faq-where-is-the-main-method</link>
		<comments>http://www.kosherjava.com/2009/11/05/faq-where-is-the-main-method/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 22:08:31 +0000</pubDate>
		<dc:creator>KosherJava</dc:creator>
				<category><![CDATA[Software Dev]]></category>
		<category><![CDATA[Zmanim]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[FAQ]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.kosherjava.com/?p=215</guid>
		<description><![CDATA[Question:Where is the main method? Answer:This is a more technical variant of the &#8220;How do I install the Zmanim API Program?&#8221;, but coming from someone who already knows that it is a Java program that can’t be installed, but assumes that it can be run. The main method is the entry point to a Java [...]]]></description>
			<content:encoded><![CDATA[<img class="alignleft" src="/images/coffeeQuestion.jpg" alt="Java FAQ"/><h2>Question:</h2>Where is the main method?
<h2>Answer:</h2>This is a more technical variant of the <a href="http://www.kosherjava.com/2009/11/05/faq-how-do-i-install-the-zmanim-api-program/">&#8220;How do I install the Zmanim API Program?&#8221;</a>, but coming from someone who already knows that it is a <a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29">Java</a> program that can’t be installed, but assumes that it can be run. The <a href="http://en.wikipedia.org/wiki/Main_function#Java">main method</a> is the entry point to a Java program. Since this is a <a href="http://en.wikipedia.org/wiki/Library_%28computer_science%29">library/API</a> and not a program, it does not have a main method. The code to generate zmanim is spelled out in the <a href="http://www.kosherjava.com/zmanim-project/how-to-use-the-zmanim-api/">How to Use the Zmanim API page</a>. Below is a full example of a very simple zmanim program that outputs sunrise, sof zman krias shema and sunset for the current day in <a href="http://en.wikipedia.org/wiki/Lakewood_Township,_New_Jersey">Lakewood, NJ</a>. Please ensure that the Zmanim <a href="http://en.wikipedia.org/wiki/JAR_%28file_format%29">jar</a> (<a href="http://www.kosherjava.com/zmanim-project/downloads/">download</a>) is in your <a href="http://en.wikipedia.org/wiki/Classpath_%28Java%29">classpath</a>.
<pre class="brush: java; title: ; notranslate">
/**
 * This program is a simple demonstration of the kosherjava.com Zmanim API.
 * To compile, ensure that the Zmanim Jar is in your classpath.
 */
import net.sourceforge.zmanim.*;
import net.sourceforge.zmanim.util.*;
import java.util.TimeZone;
public class SimpleZmanim{
	public static void main(String [] args) {
		String locationName = &quot;Lakewood, NJ&quot;;
		double latitude = 40.096; //latitude of Lakewood, NJ
		double longitude = -74.222; //longitude of Lakewood, NJ
		double elevation = 0; //optional elevation
		//use a Valid Olson Database timezone listed in java.util.TimeZone.getAvailableIDs()
		TimeZone timeZone = TimeZone.getTimeZone(&quot;America/New_York&quot;);
		//create the location object
		GeoLocation location = new GeoLocation(locationName, latitude, longitude, elevation, timeZone);
		//create the ZmanimCalendar
		ZmanimCalendar zc = new ZmanimCalendar(location);
		//optionally set the internal calendar. If not set it will default to the current date
		//zc.getCalendar().set(1969, Calendar.FEBRUARY, 8);
		System.out.println(&quot;Today's Zmanim for &quot; + locationName);
		System.out.println(&quot;Sunrise: &quot; + zc.getSunrise()); //output sunrise
		System.out.println(&quot;Sof Zman Shema GRA: &quot; + zc.getSofZmanShmaGRA()); //output Sof Zman Shema GRA
		System.out.println(&quot;Sunset: &quot; + zc.getSunset()); //output sunset
	}
}
</pre>

The following would <a href="http://en.wikipedia.org/wiki/Compiler">compile</a> and <a href="http://en.wikipedia.org/wiki/Execution_%28computing%29">execute</a> this code (sample from a <a href="http://en.wikipedia.org/wiki/COMMAND.COM">DOS prompt</a> in Windows).

<pre class="brush: plain; title: ; notranslate">
C:\path\to\code&gt;javac SimpleZmanim.java

C:\path\to\code&gt;java SimpleZmanim

Today's Zmanim for Lakewood, NJ
Sunrise: Thu Nov 05 06:30:27 EST 2009
Sof Zman Shema GRA: Thu Nov 05 09:05:21 EST 2009
Sunset: Thu Nov 05 16:50:02 EST 2009
</pre>

Please see the <a href="http://www.kosherjava.com/zmanim/docs/api/">Zmanim API documentation</a> for a more complete view of the API.]]></content:encoded>
			<wfw:commentRss>http://www.kosherjava.com/2009/11/05/faq-where-is-the-main-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zmanim API 1.1 Released</title>
		<link>http://www.kosherjava.com/2009/03/27/zmanim-api-11-released/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=zmanim-api-11-released</link>
		<comments>http://www.kosherjava.com/2009/03/27/zmanim-api-11-released/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 18:49:02 +0000</pubDate>
		<dc:creator>KosherJava</dc:creator>
				<category><![CDATA[Site News]]></category>
		<category><![CDATA[Software Dev]]></category>
		<category><![CDATA[Zmanim]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Download]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Syrian Jews]]></category>
		<category><![CDATA[Zmanim API Release]]></category>

		<guid isPermaLink="false">http://www.kosherjava.com/?p=137</guid>
		<description><![CDATA[The Zmanim API 1.1 was released early this morning. Information about what changed in this release can be seen in previous posts about various beta and patch releases. A last minute change involved the removal of the misheyakir calculations commonly used by the Syrian community. The removal was due to the various different minhagim used, [...]]]></description>
			<content:encoded><![CDATA[<img class="alignleft" src="/images/SpilledCoffee.png" alt="Zmanim API Release" title="Zmanim API Release" />The Zmanim API 1.1 was released early this morning. Information about what changed in this release can be <a href="http://www.kosherjava.com/2009/02/25/zmanim-api-11-beta-3-released/">seen</a> in previous <a href="http://www.kosherjava.com/2008/04/17/zmanim-api-11-release-candidate-available/">posts</a> about various <a href="http://www.kosherjava.com/2008/07/17/zmanim-api-11-beta-2-released/">beta</a> and <a href="http://www.kosherjava.com/2008/04/13/fix-to-noaa-sunrisesunset-algorithm/">patch</a> <a href="http://www.kosherjava.com/2008/02/07/updated-zmanim-jar-released-please-download-the-latest/">releases</a>. A last minute change involved the removal of the <em>misheyakir</em> calculations commonly used by the Syrian community. The removal was due to the various different minhagim used, and <a href="http://en.wikipedia.org/wiki/Moetzes_Gedolei_HaTorah#Current_members">Chacham Yosef Harari-Raful</a> not endorsing any one, or including any, in his calendar. The API is flexible enough to be used for any calculation wanted by the various Syrian shuls even without &#8220;native&#8221; support for a built in &#8220;Ateret Torah&#8221; <em>misheyakir</em>. Some missing JavaDocs were also added.

I would like to again thank Rabbi Rachamim Ashkenazi the publisher of a zmanim calendar for the Syrian Community, and <a href="http://www.linkedin.com/pub/4/4a/930">Victor Grazi</a> for his input, testing and technical expertise used for adding the new “Ateret Torah” zmanim.


The main download is the <a href="http://www.kosherjava.com/zmanim/release/zmanim-1.1.zip">Zmanim 1.1 release</a> zip file that includes source files and <a href="http://www.kosherjava.com/zmanim/docs/api/">JavaDoc documentation</a>. Also available for download (included in the above zip file) is the main <a href="http://www.kosherjava.com/zmanim/lib/zmanim-1.1.jar">zmanim-1.1.jar</a> and the new <a href="http://www.kosherjava.com/zmanim/lib/zmanimAstronomical-1.1_beta_3.jar">zmanimAstronomical-1.1.jar</a> that only includes the <a href="http://www.kosherjava.com/zmanim/docs/api/net/sourceforge/zmanim/AstronomicalCalendar.html">AstronomicalCalendar</a> and supporting classes. Additional detail on the downloads can be seen on the <a href="http://www.kosherjava.com/zmanim-project/downloads/">Zmanim Download page</a>]]></content:encoded>
			<wfw:commentRss>http://www.kosherjava.com/2009/03/27/zmanim-api-11-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

