Here you can find the source of stdNewDate(String tzDiff)
public static Date stdNewDate(String tzDiff)
//package com.java2s; /*// www . jav a 2 s . c o m * Copyright (C) 2012 Krawler Information Systems Pvt Ltd * All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; public class Main { public static Date stdNewDate(String tzDiff) { Calendar cal = Calendar.getInstance(); Calendar cal1 = new GregorianCalendar(TimeZone.getTimeZone("GMT" + tzDiff)); try { Date dt = new Date(); cal1.setTimeInMillis(dt.getTime()); cal.set(Calendar.YEAR, cal1.get(Calendar.YEAR)); cal.set(Calendar.MONTH, cal1.get(Calendar.MONTH)); cal.set(Calendar.DAY_OF_MONTH, cal1.get(Calendar.DAY_OF_MONTH)); cal.set(Calendar.HOUR_OF_DAY, cal1.get(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, cal1.get(Calendar.MINUTE)); cal.set(Calendar.SECOND, cal1.get(Calendar.SECOND)); cal.set(Calendar.MILLISECOND, cal1.get(Calendar.MILLISECOND)); } catch (Exception ex) { ex.printStackTrace(); } finally { return cal.getTime(); } } }