timedatarecord.java

来自「A Java Framework for connecting to and e」· Java 代码 · 共 90 行

JAVA
90
字号
package com.libGPS4j2me.devices.StdGPS;import com.libGPS4j2me.ITime;import com.libGPS4j2me.IDate;/** * * @author Loreto Parisi */public class TimeDataRecord implements ITime, IDate {        /** Month (1-12) */	protected short month;	/** Day (1-31) */	protected short day;	/** Year. */	protected int year;	/** Hour of the day. */	protected int hour;	/** Minute of the hour. */	protected short minute;	/** Second of the minute. */	protected short second;    /** Creates a new instance of TimeDataRecord */    public TimeDataRecord(DataRecord record) {		try {			day = Short.parseShort(record.dateTimeOfFix.substring(9,10));			month = Short.parseShort(record.dateTimeOfFix.substring(12,13));			year = Integer.valueOf(record.dateTimeOfFix.substring(15,16)).intValue();			hour = Integer.valueOf(record.dateTimeOfFix.substring(0,1)).intValue();			minute = Short.parseShort(record.dateTimeOfFix.substring(3,4));			second = Short.parseShort(record.dateTimeOfFix.substring(6,7));        } catch(Exception e) {			System.out.println("Exception: "+ e.getMessage());		}    }    /** Returns the day of the month. */	public short getDay() {		return day;	}	/** Returns the month. */	public short getMonth() {		return month;	}	/** returns the year. */	public int getYear() {		return year;	}	/** Returns the hour of the day. */	public int getHours() {		return hour;	}	/** Returns the minute of the hour. */	public short getMinutes() {		return minute;	}	/** Returns the second of the minute.*/	public short getSeconds() {		return second;	}        /**	* Returns the value of this packet in a human-readable format.	*/	public String toString() {		StringBuffer res = new StringBuffer();		if (hour < 10)			res.append("\n0");		res.append("\n" + hour +":");		if (minute < 10)			res.append("0");		res.append(minute +":");		if (second < 10)			res.append("0");		res.append(second + "/");		res.append(day + ".");		res.append(month + "." + year);		return res.toString();	}}

⌨️ 快捷键说明

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