Java tutorial
//package com.java2s; /*********************************************************************************************************************** * Copyright (c) 2008 empolis GmbH and brox IT Solutions GmbH. All rights reserved. This program and the accompanying * materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: Daniel Stucky (empolis GmbH) - initial API and implementation **********************************************************************************************************************/ import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** * Encodes a date. * * @param javaDate * a Date * @return a String */ public static String encodeDate(Date javaDate) { final SimpleDateFormat df = new SimpleDateFormat(); df.applyPattern("yyyy-MM-dd"); return df.format(javaDate); } }