Here you can find the source of GetDayOfWeek(long p)
public static int GetDayOfWeek(long p)
//package com.java2s; /*/*from w w w .j av a 2 s . c o m*/ * Encog(tm) Core v3.1 - Java Version * http://www.heatonresearch.com/encog/ * http://code.google.com/p/encog-java/ * Copyright 2008-2012 Heaton Research, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * For more information on Heaton Research copyrights, licenses * and trademarks visit: * http://www.heatonresearch.com/copyright */ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static final int YEAR_OFFSET = 10000; public static final int MONTH_OFFSET = 100; public static int GetDayOfWeek(long p) { Date t = long2Date(p); GregorianCalendar gc = new GregorianCalendar(); gc.setTime(t); switch (gc.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: return 0; case Calendar.MONDAY: return 1; case Calendar.TUESDAY: return 2; case Calendar.WEDNESDAY: return 3; case Calendar.THURSDAY: return 4; case Calendar.FRIDAY: return 5; case Calendar.SATURDAY: return 6; default: // no way this should happen! return -1; } } public static Date long2Date(long l) { long rest = (long) l; int year = (int) (rest / YEAR_OFFSET); rest -= year * YEAR_OFFSET; int month = (int) (rest / MONTH_OFFSET); rest -= month * MONTH_OFFSET; int day = (int) rest; GregorianCalendar gc = new GregorianCalendar(year, month, day); return gc.getTime(); } }