⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reservationidhelper.java

📁 hotel management system
💻 JAVA
字号:
/*
 * Copyright 2005-2007 Kevin A. Lee
 *
 * 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.
 *
 */
package net.sourceforge.hoteldj.web;

import java.text.DecimalFormat;
import java.text.ParseException;

/**
 * Format the reservation id so that it is customer consumable
 * 
 * @author Kevin A. Lee
 * @email kevin.lee@buildmeister.com
 *
 */
public class ReservationIDHelper {
	
	public String idPattern = "HJD0000000";
	
	/**
	 * @return the idPattern
	 */
	public String getIdPattern() {
		return this.idPattern;
	}

	/**
	 * @param idPattern the idPattern to set
	 */
	public void setIdPattern(String idPattern) {
		this.idPattern = idPattern;
	}
	
	/**
	 * convert an Integer to a formatted string
	 * @param id
	 * @return String
	 */
	public String idToFormatted(Integer id) {
		
		DecimalFormat myFormatter = new DecimalFormat(idPattern);
		return myFormatter.format(id);

	}
	
	/**
	 * convert a formatter string to an Integer
	 * @param formatted
	 * @return Integer
	 */
	public Integer formattedtoId(String formatted) {
		
		DecimalFormat myFormatter = new DecimalFormat(idPattern);
		Number id = null;
		try {
			id = myFormatter.parse(formatted);
		} catch (ParseException ex) {
			// TODO Auto-generated catch block
			ex.printStackTrace();
		}
		Integer realId = new Integer(id.intValue());
		return realId;
		
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -