Java tutorial
//package com.java2s; /* * **************************************************************************** * Copyright (c) 2015, MasterCard International Incorporated and/or its * affiliates. All rights reserved. * <p/> * The contents of this file may only be used subject to the MasterCard * Mobile Payment SDK for MCBP and/or MasterCard Mobile MPP UI SDK * Materials License. * <p/> * Please refer to the file LICENSE.TXT for full details. * <p/> * TO THE EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT * WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NON INFRINGEMENT. TO THE EXTENT PERMITTED BY LAW, IN NO EVENT SHALL * MASTERCARD OR ITS AFFILIATES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. * ***************************************************************************** */ import java.util.Calendar; import java.util.Date; public class Main { public static Date getDateFromHexString(String hexString) { Calendar c = Calendar.getInstance(); int year = Integer.parseInt(hexString.substring(0, 2)) + 2000; int month = Integer.parseInt(hexString.substring(2, 4)); int day = Integer.parseInt(hexString.substring(4, 6)); c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, month - 1); c.set(Calendar.DAY_OF_MONTH, day); return c.getTime(); } }